Skip to content

ui

Description

Interfacing with the user interface and overlay


button

ui.button(tab, column, name, callback)

Creates a new button. The return value should not be used with ui.set/ui.get.

checkbox

ui.checkbox(tab, column, name)

Creates a new checkbox. Returns a value that can be passed to ui.get/ui.set.

color_picker

ui.color_picker(tab, column, name, r, g, b, a)

Creates a new color picker. The color picker is placed to the right of the previous menu item.

combobox

ui.combobox(tab, column, name, ...)

Creates a new combobox. Returns a value that can be passed to ui.get/ui.set.

get

ui.get(item)

For a checkbox, returns true or false. For a slider, returns an integer/float. For a combobox, returns a string. For a multiselect combobox, returns an array of strings. For a hotkey, returns true if the hotkey is active. For a color picker, returns r, g, b, a(, effect, speed if present). Throws an error on failure.

hotkey_button

ui.hotkey_button(tab, column, name, inline, default)

Creates a new hotkey button. Returns a value that can be passed to ui.get to see if the hotkey is pressed.

is_menu_open

ui.is_menu_open()

Returns true if the menu is currently open.

listbox

ui.listbox(tab, container, name, items)

Creates a new list box. Calling ui.get on a list box will return the zero-based index of the currently selected string.

ui.menu_pos()

Returns the x, y of the menu, even when closed.

mouse_pos

ui.mouse_pos()

Returns current x, y mouse coordinates.

multiselect

ui.multiselect(tab, column, name, ...)

Creates a new multiselect. Returns a value that can be passed to ui.get/ui.set.

name

ui.name(item)

Returns the display name of an item.

reference

ui.reference(tab, column, name)

Do not call this from inside a function. Returns a reference that can be passed to ui.set/ui.get. This allows you to access built-in menu items. This function returns multiple values when the specified menu item is followed by unnamed menu times, like color pickers or hotkeys.

set

ui.set(item)

For checkboxes, pass true or false. For a slider, pass a integer/float that is within the slider’s minimum/maximum values. For a combobox, pass a string value. For textboxes, pass a string value. For a multiselect, pass zero or more strings. For referenced buttons, the callback is ignored regardless of the value. For color pickers, pass the arguments r, g, b, a(, effect, speed).

set_callback

ui.set_callback(item, callback)

Sets the callback of a custom menu item.

set_enabled

ui.set_enabled(item, enabled)

Sets the enabled state of the menu item.

set_visible

ui.set_visible(item, visible)

Sets the visibility of the menu item.

string

ui.string(tab, column, name)

Creates a string UI element. Can be used to store arbitrary strings in configs. No menu item is created. Returns a rvalue that can be passed to ui.get/ui.set.

text

ui.text(tab, column, name)

Creates a new text label.

textbox

ui.textbox(tab, column, name)

Creates a new text box. Returns a value that can be passed to ui.get.

type

ui.type(item)

Returns the type of an element.