Lua · Variables · Script UI

menu

Build the script's own page: text, buttons, inputs, lists and images.

Define function on_menu() and call menu.* inside it. It runs every frame while the script's tab is open. Widgets are immediate-mode: pass the current value in, get the new value back, and keep it in your own variable.

Outside on_menu the widgets do nothing and return the value you passed in (buttons return false). Keep the widgets in the same order every frame; the order is how each widget is told apart.

Every click and change is logged to the console as menu: <label> = <value>.

FunctionWhat it does
menu.text(text)A line of text.
menu.section(title)A section heading.
menu.separator()A thin line.
menu.spacing()Some empty space.
menu.same_line()Puts the next widget to the right of the last button. Works only right after a button.
menu.button(label)A button.
menu.checkbox(label, value)A checkbox.
menu.slider(label, value, min, max[, decimals])A slider.
menu.combo(label, index, items)A dropdown.
menu.color(label, col)A colour picker.
menu.keybind(label, vk)A key picker.
menu.input(label, text)A one-line text field, up to 255 bytes.
menu.tooltip(text)A hover tooltip on the widget drawn just before it.
menu.progress(label, value)A progress bar.
menu.list(label, selected, items[, rows])A scrolling list.
menu.image(handle, w, h)An image from draw.load_image. The width is capped to the page width.

#menu.text

menu.text(text)

A line of text.

#menu.section

menu.section(title)

A section heading.

#menu.separator

menu.separator()

A thin line.

#menu.spacing

menu.spacing()

Some empty space.

#menu.same_line

menu.same_line()

Puts the next widget to the right of the last button. Works only right after a button.

#menu.button

menu.button(label)

A button.

Returns

boolean
true on the frame it was clicked.
Example
if menu.button("Reset") then kills = 0 end

#menu.checkbox

menu.checkbox(label, value)

A checkbox.

Returns

boolean
New value.
Example
show = menu.checkbox("Show", show)

#menu.slider

menu.slider(label, value, min, max[, decimals])

A slider.

Arguments

labelstring
-
valuenumber
-
min, maxnumber
-
decimalsintegeroptional
Default 0 when all numbers are whole, otherwise 2.

Returns

number
New value.

#menu.combo

menu.combo(label, index, items)

A dropdown.

Arguments

labelstring
-
indexinteger
1-based.
itemsstring[]
-

Returns

integer
New 1-based index.

#menu.color

menu.color(label, col)

A colour picker.

Returns

integer
New colour.

#menu.keybind

menu.keybind(label, vk)

A key picker.

Returns

integer
New key code.

#menu.input

menu.input(label, text)

A one-line text field, up to 255 bytes.

Returns

string
New text.
Example
name = menu.input("Name", name)

#menu.tooltip

menu.tooltip(text)

A hover tooltip on the widget drawn just before it.

#menu.progress

menu.progress(label, value)

A progress bar.

Arguments

labelstring
-
valuenumber
0 to 1.

#menu.list

menu.list(label, selected, items[, rows])

A scrolling list.

Arguments

labelstring
Can be empty.
selectedinteger
1-based, 0 for none.
itemsstring[]
-
rowsintegeroptional
Visible rows, 2 to 16. Default 6.

Returns

integer
New selection.

#menu.image

menu.image(handle, w, h)

An image from draw.load_image. The width is capped to the page width.