Lua · Variables · Script UI

ui

Script settings that are saved and shown on the script's page.

Call these once at the top of the script. Each call creates a control on the script's page under SCRIPT and returns its current value. Read the value later with ui.get(id). Values are saved per script and survive restarts and reloads.

The id is the saved name; change the label freely but keep the id the same, or the saved value is lost.

FunctionWhat it does
ui.checkbox(id, label[, default])An on/off switch.
ui.slider(id, label, min, max[, default])A number slider. Whole numbers when min, max and default are all whole and the range is at least 2; otherwise two decimals.
ui.combo(id, label, items[, default])A dropdown.
ui.color(id, label[, default])A colour picker with alpha.
ui.keybind(id, label[, default])A key picker.
ui.get(id)The current value of a control made with the functions above.

#ui.checkbox

ui.checkbox(id, label[, default])

An on/off switch.

Arguments

idstring
Saved name.
labelstring
Text next to it.
defaultbooleanoptional
Default false.

Returns

boolean
Current value.
Example
ui.checkbox("show", "Show panel", true)

#ui.slider

ui.slider(id, label, min, max[, default])

A number slider. Whole numbers when min, max and default are all whole and the range is at least 2; otherwise two decimals.

Arguments

idstring
-
labelstring
-
minnumber
-
maxnumber
-
defaultnumberoptional
Default min.

Returns

number
Current value, kept inside min to max.
Example
ui.slider("size", "Text size", 10, 32, 16)
ui.slider("speed", "Fade speed", 0.5, 5, 2.0)

#ui.combo

ui.combo(id, label, items[, default])

A dropdown.

Arguments

idstring
-
labelstring
-
itemsstring[]
Choices.
defaultintegeroptional
1-based index. Default 1.

Returns

integer
1-based index of the choice.
Example
local styles = { "Minimal", "Boxed", "Bar" }
ui.combo("style", "Style", styles, 1)
local chosen = styles[ui.get("style")]

#ui.color

ui.color(id, label[, default])

A colour picker with alpha.

Arguments

idstring
-
labelstring
-
defaultcoloroptional
Default white.

Returns

integer
Packed colour.

#ui.keybind

ui.keybind(id, label[, default])

A key picker.

Arguments

idstring
-
labelstring
-
defaultintegeroptional
Virtual-key code. Default 0 (none).

Returns

integer
Key code, 0 when none.
Example
ui.keybind("toggle", "Toggle key", 0x75)

#ui.get

ui.get(id)

The current value of a control made with the functions above.

Arguments

idstring
-

Returns

any | nil
nil when no control has this id.