MenuStyleThe display backend a Menu renders through — the value of Menu.style.
Chat = "chat"Center = "center"@s2script/sdk/menu
interactive player menus (chat + center backends).
import { MenuStyle } from "@s2script/sdk/menu";Author-time types ship in the npm package; the engine injects the runtime at plugin load. Add @s2script/sdk to your plugin's dependencies.
Generated from the shipped type definitions.
MenuStyleThe display backend a Menu renders through — the value of Menu.style.
Chat = "chat"Center = "center"MenuCancelReasonWhy a menu closed without a selection — the MenuCancelEvent.reason.
Exit = 0close/cancel was called).Timeout = 1display seconds elapsed with no selection.Disconnect = 2NewMenu = 3MenuSelectEventPayload for Menu.onSelect — the item a player picked.
readonly slot: numberreadonly item: numberreadonly info: stringinfo string the item was added with — the machine key, returned to your handler.readonly display: stringMenuCancelEventPayload for Menu.onCancel — a menu that closed without a selection.
readonly slot: numberreadonly reason: MenuCancelReasonMenuA slot-based interactive menu. Add items, wire Menu.onSelect/Menu.onCancel, then Menu.display to a player slot. The model paginates automatically (7 items per chat page) and picks a renderer by Menu.style, falling back to Chat when the style's renderer is unregistered. Only one menu is active per slot; displaying a new one supersedes the old (MenuCancelReason.NewMenu).
import { Menu, MenuStyle } from "@s2script/sdk/menu";
const m = new Menu("s2script Menu Demo");
m.style = MenuStyle.Center;
m.freezePlayer = true; // freeze movement while the WASD menu is open (nav still works)
m.addItem("hp", "Heal to 100");
m.addItem("noclip", "Toggle Noclip");
m.onSelect(e => { console.log(`picked ${e.info} (slot ${e.slot})`); });
m.display(slot, 30);title: stringstyle: MenuStyleexitButton: booleanfreezePlayer: booleanaddItem(info: string, display: string, opts?: { disabled?: boolean }): voidinfo is returned to onSelect; display is shown.onSelect(handler: (e: MenuSelectEvent) => void): voidonCancel(handler: (e: MenuCancelEvent) => void): voiddisplay(slot: number, seconds?: number): voidseconds (0 = until selection/cancel/disconnect).close(slot: number): voidslot early.registerRenderer(name: string, renderer: MenuRenderer): voidMenuSessionA live display of one menu to one slot, passed to a MenuRenderer. Owns the page/cursor state and exposes the input verbs a renderer drives.
readonly slot: numberview(): { title: string; lines: MenuLine[]; page: number; pageCount: number; exit: boolean }pickNumber(n: number): voidmoveUp(): voidmoveDown(): voidconfirm(): voidcancel(): voidMenuLineOne rendered line of a MenuSession view.
text: stringkey: string | nullselectable: booleancursor?: booleancontrol?: string"back", "next", or "exit" (absent on item lines).index?: numberMenuRendererA display backend for Menu — registered via Menu.registerRenderer, driven with a MenuSession.
open(session: MenuSession): voidupdate(session: MenuSession): voidclose(slot: number): voidslot (the menu closed).