MenuEntry

Methods
32
Fields
None

Getting one

client:createMenuEntry(…)
client:getMenu():createMenuEntry(…)

Methods

MethodReturnsDescription
getOption()stringThe option text: "Walk here", "Attack", ...
setOption(string)MenuEntrySet the option text.
getTarget()stringThe target text, with its colour tags (<col=ffff00>Goblin<col=ff00> (level-2)); empty when the option has no target.
setTarget(string)MenuEntrySet the target text.
getIdentifier()numberThe identifier: the loc, NPC index, item, player index or widget op the action targets, depending on its type.
setIdentifier(number)MenuEntrySet the identifier. On a client entry it is what the action then uses.
getType()MenuActionThe action, without the deprioritize offset (isDeprioritized() says that).
setType(MenuAction)MenuEntrySet the action, keeping the deprioritize state. Within the entry's own action (an NPC op for another NPC op) the client's own action runs t…
getParam0()numberThe first parameter: a scene x, a widget child index, ...
setParam0(number)MenuEntrySet the first parameter.
getParam1()numberThe second parameter: a scene y, a packed widget id, ...
setParam1(number)MenuEntrySet the second parameter.
isForceLeftClick()booleanWhether a left click runs it even where the client would open the menu (shift click).
setForceLeftClick(boolean)MenuEntrySet whether a left click runs it even where the client would open the menu.
getWorldViewId()numberThe world view the entry belongs to; -1 for none.
setWorldViewId(number)MenuEntrySet the world view id.
isDeprioritized()booleanWhether it is deprioritized (+2000 on its opcode): an "Attack" the attack-option setting demotes, a low-priority follower op, a player opti…
setDeprioritized(boolean)MenuEntryDeprioritize it (or stop): it sorts below every entry that is not. A change made before the client's last sort places it.
onClick((MenuEntry) -> ())MenuEntryRun callback(entry) when the entry is clicked: after every MenuOptionClicked subscriber, whether or not one consumed the click. Replace…
copyOnClick(MenuEntry)MenuEntryCopy from's onClick callback onto this entry: clone:copyOnClick(entry). A member cannot hand back a Luau function, so onClick has n…
isItemOp()booleanWhether it is an inventory item op ("Use" and "Examine" are not).
getItemOp()numberThe item op 1-5 of an inventory item op, else -1. The shift-click op (identifier 1) is the op of the item in the widget slot the entry name…
getItemId()numberThe item id, or -1.
setItemId(number)MenuEntrySet the item id.
getWidget()Widget?The widget the entry acts on (a CC_OP, WIDGET_TARGET, WIDGET_CONTINUE, ...): client:getWidget(getParam1()), or its dynamic child `g…
getNpc()NPC?The NPC the entry targets (an NPC option, a use on an NPC, Examine), by index getIdentifier() in the entry's world view, or nil.
getPlayer()Player?The player the entry targets (a player option, a use on a player, a CLIENT_PLAYER entry) by index getIdentifier(); for WALK, the hove…
getActor()Actor?getNpc(), else getPlayer().
getSubMenu()Menu?The entry's submenu, or nil when it has none.
createSubMenu()MenuA new, empty submenu for the entry, replacing any. Raises where the client's menu cannot hold one.
deleteSubMenu()()Remove the entry's submenu.
equals(any)booleanWhether other is this same MenuEntry, as == answers it (false for a value of another class).

Returned by

MethodReturnsDescription
Client.createMenuEntryMenuEntryAdd an entry at idx (getMenu():createMenuEntry(idx); -1 is the top).
Client.getMenuEntries{MenuEntry}The menu's entries, in the client's order (getMenu():getMenuEntries()).
Menu.createMenuEntryMenuEntryCreate a new entry at idx (a negative index counts from the end: -1 puts it on top) and return it: option and target empty, type `MenuAct…
Menu.getMenuEntries{MenuEntry}The menu's entries, bottom first: a 1-based array whose last element is the top entry.
MenuEntryAdded.getMenuEntryMenuEntryThe entry the client added, live. From a legacy delivery (a build without the menu sites), a detached, read-only entry with the event's fie…
MenuOpened.getFirstEntryMenuEntry?The entry shown at the top (the array's last), or nil for an empty menu.
MenuOpened.getMenuEntries{MenuEntry}The menu's entries, bottom first: the last is shown at the top.
MenuOptionClicked.getMenuEntryMenuEntryThe clicked entry, live. From a legacy delivery (a build without the menu sites), a detached, read-only entry with the event's fields: the…

Method details

getTarget

getTarget: (MenuEntry) -> string

The target text, with its colour tags (<col=ffff00>Goblin<col=ff00> (level-2)); empty when the option has no target.

getIdentifier

getIdentifier: (MenuEntry) -> number

The identifier: the loc, NPC index, item, player index or widget op the action targets, depending on its type.

setType

setType: (MenuEntry, MenuAction) -> MenuEntry

Set the action, keeping the deprioritize state. Within the entry's own action (an NPC op for another NPC op) the client's own action runs the new op; any other type runs through Bento's intent for it when the entry is clicked (a CLIENT type runs nothing but onClick; WALK walks to the hovered tile, whatever the params).

getParam0

getParam0: (MenuEntry) -> number

The first parameter: a scene x, a widget child index, ...

getParam1

getParam1: (MenuEntry) -> number

The second parameter: a scene y, a packed widget id, ...

isForceLeftClick

isForceLeftClick: (MenuEntry) -> boolean

Whether a left click runs it even where the client would open the menu (shift click).

isDeprioritized

isDeprioritized: (MenuEntry) -> boolean

Whether it is deprioritized (+2000 on its opcode): an "Attack" the attack-option setting demotes, a low-priority follower op, a player option with a priority, or one a plugin deprioritized. A type that is low by itself (loc op 5, Examine, CC_OP_LOW_PRIORITY) is not.

setDeprioritized

setDeprioritized: (MenuEntry, boolean) -> MenuEntry

Deprioritize it (or stop): it sorts below every entry that is not. A change made before the client's last sort places it.

onClick

onClick: (MenuEntry, (MenuEntry) -> ()) -> MenuEntry

Run callback(entry) when the entry is clicked: after every MenuOptionClicked subscriber, whether or not one consumed the click. Replaces an earlier callback; returns the entry.

copyOnClick

copyOnClick: (MenuEntry, MenuEntry) -> MenuEntry

Copy from's onClick callback onto this entry: clone:copyOnClick(entry). A member cannot hand back a Luau function, so onClick has no getter to read it with. The callback still runs in the plugin that put it on from; a from with none takes this entry's off. Returns this entry.

isItemOp

isItemOp: (MenuEntry) -> boolean

Whether it is an inventory item op ("Use" and "Examine" are not).

getItemOp

getItemOp: (MenuEntry) -> number

The item op 1-5 of an inventory item op, else -1. The shift-click op (identifier 1) is the op of the item in the widget slot the entry names.

getWidget

getWidget: (MenuEntry) -> Widget?

The widget the entry acts on (a CC_OP, WIDGET_TARGET, WIDGET_CONTINUE, ...): client:getWidget(getParam1()), or its dynamic child getParam0() when that is not -1. nil for other types, an interface that is not loaded, or an empty slot.

getNpc

getNpc: (MenuEntry) -> NPC?

The NPC the entry targets (an NPC option, a use on an NPC, Examine), by index getIdentifier() in the entry's world view, or nil.

getPlayer

getPlayer: (MenuEntry) -> Player?

The player the entry targets (a player option, a use on a player, a CLIENT_PLAYER entry) by index getIdentifier(); for WALK, the hovered player at getIdentifier() - 1. nil when there is none.

createSubMenu

createSubMenu: (MenuEntry) -> Menu

A new, empty submenu for the entry, replacing any. Raises where the client's menu cannot hold one.

equals

equals: (MenuEntry, any) -> boolean

Whether other is this same MenuEntry, as == answers it (false for a value of another class).