Docs · menu

menu

27 menu commands, generated from the engine's own registry — signatures, parameters and a worked example each. A does something command acts on the game; a needs x() one answers a confident wrong answer when its client hooks are missing.

clickMenu does something returns bool
clickMenu(command: string) -> bool

Clicks a row of a menu that is already open. Composed here rather than taken from the API, which clicks a row it is handed: this finds the row whose command matches and then hands it to the same aim-and-confirm click every interact uses. False when no menu is open or no row matches.

ParameterTypeWhat it does
commandrequired string the option to click
Example
if menuContains("Attack") { clickMenu("Attack") }
closeMenu does something returns bool
closeMenu() -> bool

Closes an open menu by moving the pointer off it, never by clicking - a left click on the world walks the character there or attacks whatever is standing on the spot. True when no menu is up afterwards.

Example
closeMenu()
hoveredSlot returns int
hoveredSlot() -> int

Which menu row the pointer is sitting on, 0 at the top, or -1 for none. For reporting: nothing needs it in order to click.

Example
print("pointer is on row", hoveredSlot())
lastMenuAction returns string
lastMenuAction() -> string

The verb of the most recent action as it was drawn, or empty.

Example
print(lastMenuAction())
lastMenuKind returns string
lastMenuKind() -> string

The kind of the most recent action, lower case, or empty. The same value 'on menu' would have been given, for a script that would rather poll.

Example
if lastMenuKind() == "drop_item" { print("something went on the floor") }
lastMenuTarget returns string
lastMenuTarget() -> string

The target of the most recent action as it was drawn, or empty.

Example
print(lastMenuTarget())
menuAction returns string
menuAction() -> string

The verb as the menu drew it, like "Attack" or "Take". This is display text and changes with the server; match on menuKind when you can.

Example
print(menuAction(), menuTarget())
menuActionCount returns int
menuActionCount() -> int

How many menu actions this client has sent since it started. Compare it between passes to notice that something happened without caring what.

Example
let before = menuActionCount()
menuContains returns bool
menuContains(command: string) -> bool

Whether the open menu offers this option. Case is ignored, and the target is not compared - "Attack" matches "Attack Goblin".

ParameterTypeWhat it does
commandrequired string the option to look for
Example
if menuContains("Talk-to") { clickMenu("Talk-to") }
menuCount returns int
menuCount() -> int

How many options the open menu has, or zero when none is open.

Example
if menuCount() > 0 { closeMenu() }
menuDrop returns drop?
menuDrop() -> drop?

The ground item the action was aimed at, or none.

Example
let loot = menuDrop()
menuIndex returns int
menuIndex() -> int

The server index of the actor the action was aimed at, or -1.

Example
print("index", menuIndex())
menuItem returns item?
menuItem() -> item?

The inventory item the action was aimed at, or none.

Example
let used = menuItem()
menuKind returns string
menuKind() -> string

The kind of the action being handled, lower case, like "attack_npc", "take_item" or "cast_on_npc". Empty when nothing has happened yet. Inside 'on menu' this is the action the block was called for; outside it is the most recent one.

Example
if menuKind() == "take_item" { print("picked something up") }
menuName returns string
menuName() -> string

The player name the action carried, for the actions aimed at a player. Empty for everything else.

Example
if menuKind() == "trade_player" { print("trading", menuName()) }
menuNpc returns npc?
menuNpc() -> npc?

The npc the action was aimed at, or none when it was not aimed at one. The ordinary npc commands work on it.

Example
let it = menuNpc()
menuObject returns object?
menuObject() -> object?

The object the action was aimed at, or none.

Example
let tree = menuObject()
menuOpcode returns int
menuOpcode() -> int

The packet the action sent, or -1. For working out what a build does, not for ordinary scripting.

Example
print("opcode", menuOpcode())
menuOptions returns list<string>
menuOptions() -> list<string>

The lines of the open menu, as the player reads them, or an empty list when none is open.

Example
for option in menuOptions() { print(option) }
menuPlayer returns player?
menuPlayer() -> player?

The player the action was aimed at, or none.

Example
let them = menuPlayer()
menuSlot returns int
menuSlot() -> int

The inventory slot the action used, or -1. This is the slot of the item being used ON something, which is not the same as menuItem for a use-on action.

Example
if menuSlot() >= 0 { print("used slot", menuSlot()) }
menuSpell returns int
menuSpell() -> int

The spell the action cast, as a spell id, or -1 when it cast nothing.

Example
if menuSpell() >= 0 { print("cast spell", menuSpell()) }
menuTarget returns string
menuTarget() -> string

The target as the menu drew it, like "Goblin" or "Coins". Display text, same caveat as menuAction.

Example
if menuTarget() == "Chicken" { print("pecking order") }
menuTile returns tile?
menuTile() -> tile?

Where on the ground the action happened, for the actions that name a tile. None for the rest.

Example
let where = menuTile()
menuWall returns wall?
menuWall() -> wall?

The wall or door the action was aimed at, or none.

Example
let door = menuWall()
menuWorks returns bool
menuWorks() -> bool

Whether menu actions can be read on this client at all. False on a server whose menu dispatch is not woven, where 'on menu' never runs and the readers answer empty.

Example
if menuWorks() == false { print("no menu actions on this server") }
recentMenuKinds returns list<string>
recentMenuKinds() -> list<string>

The kinds of the last few actions, oldest first, so a pass-based script can catch several that happened between its passes.

Example
if contains(recentMenuKinds(), "take_item") { print("picked something up") }