Declare at the top level, not in
tick or render. There is no draw callback: you read
control.value or listen for change. Everything is removed when the script unloads.Overview
Layout
page, group, row.Controls
switch, slider, combo, multi, color, input, button, text.Reactive values
signal, computed, effect, batch.Keybinds
key, mode, active, press / release.Paths and persistence
id, persist, dispose.Window
open, close, on.Layout
page
id) again returns the same page, and the
options of that repeat call are ignored. icon is a Tabler icon name; tabs sort by order
(default 0). page.show() brings the tab to the front.
group
page. Without column, a page’s groups are split down the
middle in declaration order.
row
build runs right away with the row.
Controls
Every container (page, group, row) has the same builders. The first argument is the label.
A control has these members:
switch
key attaches a hotkey; true is an unbound "hold" bind.
slider
combo
items. The value is the item text; writing takes an item or its index. The items type
the value, so combo("Mode", ["Legit", "Rage"]) is "Legit" | "Rage" without as const.
multi
items. The value is the picked items in list order; writing takes items and/or
indices. Replacing items drops picks that are gone.
color
ColorLike. Default white. key works like on a switch.
input
button
button.on("click", fn) subscribes, button.click() runs the listeners as a real
click would.
text
Reactive values
label, visible, disabled and a text’s text accept a function, as an option or an
assignment. It runs now and again whenever a control value, a key.active or a signal it read
changes. Assigning again replaces it.
error
event.
signal
value to something new fires change and re-runs whatever read it.
Mutating an object in place doesn’t count.
computed
compute re-runs when something it read changes; change
fires when the result differs.
effect
fn now and again whenever anything it read changes, until the Subscription is disposed.
batch
fn returns, then runs each affected function once. Returns what fn returns.
Keybinds
A switch, color or toggle group declared withkey has a KeyBind at control.key. The user can
rebind the key and change the mode in the menu; a persisted control saves both.
The
key option ({ key?, mode? }) is only a default: once the user binds or clears the key, theirs wins.
Paths and persistence
Saved values are keyed by path: the parent’s path plus theid option or the slugified label.
ui.page("Aim").group("Main").slider("FOV") is aim/main/fov. Rows add nothing.
- Two controls on the same path throw
EEXIST. Give one anid(buttons and texts don’t clash). - Renaming a label moves the path and loses the saved value. Set
idwhen the label may change. persist: falsekeeps a value for the session only.
dispose
alive is false, reads return null and
writes throw. Declaring the same path again creates a fresh node. Signals and computeds have dispose() too.