Tabs, cards and controls on the Scripts page, floating windows, and draggable overlay widgets.
since 1.0no permission needed
A script's interface lives in three places. A tab (ui.tab) is a page on the Scripts page, built from cards that hold controls. A window (ui.window) is a floating panel shown while the menu is open. A widget (ui.widget) is a box on the overlay itself that you draw into and the user can drag.
Tab, window and card functions are immediate mode: the function you pass is called again every frame the page is visible, and controls return their current value each time. Control functions only work inside ui.card (or inside a window body); calling them anywhere else is an error. Cards cannot be nested. Register tabs, windows and widgets once, when the script loads (at most 8 of each).
A control with an id keeps its value in the store under that key, so the value survives reloads and restarts; read it anywhere with store.get(id, default). Pass nil as the id for a control that should not be saved.
Registers a floating window. It is shown only while the menu is open, like a tool. body is built like a tab and may call ui.card.
Parameter
Type
Description
options
table
{id, title, size = {w, h}, open, body = fn}. id is required (2 to 48 characters from a-z 0-9 - _); size defaults to a small panel; open is the starting state.
lua
ui.window{ id = "tool", title = "Tool", size = { 360, 200 }, body = function()
ui.card("Hello", function() ui.text("inside a window") end)
end }
Registers an overlay widget. Draw into it with the draw.* functions in widget coordinates (0, 0 is its top left corner; drawing is clipped to its size). The user drags it by its top strip while the menu is open and its position is saved. With the menu closed the overlay lets the mouse through to the game, so interactive widgets can only be clicked while the menu is open.
Parameter
Type
Description
options
table
{id, name, size = {w, h}, pos = {fx, fy}, interactive, draw = fn(w)}. id is 2 to 48 characters from a-z 0-9 - _. pos is a fraction of the free space of the screen (0, 0 top left; 1, 1 bottom right), so it holds at any resolution. draw receives a WidgetContext.
A key picker. It only records which key the user chose; to react to the key being held, read it with input.key_down (needs the input permission). See input for the code table.
Parameter
Type
Description
id
string | nil
Store key.
label
string
Text.
defaultoptional
integer
A Windows virtual-key code, or 0 for none. default 0