[Z+] LUA scripting

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Doken
    Rookie
    • Oct 2008
    • 2

    [Z+] LUA scripting

    Is it possible to call a menu with an item activation?
    I'd like to make an item with multiple, selectable activation uses.

    If it's possible what is the command?
    Is there a list of available LUA commands for Z+ somewhere?

    I'd also like to be able to restrict activations based on race, level, class and realm choice. Are these possible?

    I'm aiming to make a book "shield" and a wizard staff (equipped) that have multiple spells.

    If this is possible, I'd appreciate it if someone could point me in the right direction.
  • Mangojuice
    Z+Angband Maintainer
    • Jun 2008
    • 318

    #2
    Originally posted by Doken
    Is it possible to call a menu with an item activation?
    I'd like to make an item with multiple, selectable activation uses.

    If it's possible what is the command?
    Is there a list of available LUA commands for Z+ somewhere?

    I'd also like to be able to restrict activations based on race, level, class and realm choice. Are these possible?

    I'm aiming to make a book "shield" and a wizard staff (equipped) that have multiple spells.

    If this is possible, I'd appreciate it if someone could point me in the right direction.
    It's kludgy, but you could use get_check to have the player select an option. For instance:

    if (get_check("Magic Missile? ") ~= 0) then [code]
    elseif (get_check("Detect Monsters? ") ~= 0) then [code]
    elseif (get_check("Lightning Bolt? ") ~= 0) then [code] end

    You can definitely have code dependent on the player's attributes.

    player.rp.pclass will return the code for the player's class; you compare these to things like CLASS_PALADIN.

    player.rp.prace will return the code for the player's race. I think you have to compare these manually to numbers from 0 to 30, but you could try RACE_HUMAN and see if that works.

    player.lev returns the player's current level; sometimes you can use simply "plev" for this.

    player.spell.r[0].realm returns the player's 1st realm, player.spell.r[0].realm returns the 2nd realm. You can compare these to numbers from 1-7; 1 is Life, 2 is Sorcery, 3 is Nature, 4 is Chaos, 5 is Death, 6 is Conjuration, 7 is Arcane. player.spell.r[1].realm returns the player's 2nd realm, if any. A 0 indicates no realm in that position.

    Have fun. Lua scripting really appealed to me, that's why I based my variant on Z.

    Edit: P.S. There is a list, available in the source code. If you open that up, you'll find several files in the src directory called things like "l-object.pkg" -- in those are the list of functions you can call. They are documented in the actual .c files.
    Last edited by Mangojuice; October 17, 2008, 05:51.
    -----------------------------------------
    Z+Angband: A Zangband evolution
    http://tinyurl.com/5pq2bd

    Comment

    • Doken
      Rookie
      • Oct 2008
      • 2

      #3
      Thanks for the info.
      I'll tinker around and see what I can do.

      Comment

      Working...
      😀
      😂
      🥰
      😘
      🤢
      😎
      😞
      😡
      👍
      👎