ui
Refs
functionui.is_menu_open()
is_menu_open
Returns
- Name
menu_open- Type
- boolean
- Description
- Returns true if the menu is open, otherwise returns false
Example
if ui.is_menu_open() then
logger.info('Menu open')
end
functionui.menu_position()
menu_position
Returns the menu position, regardless of whether the menu is open or not.
Returns
- Name
x- Type
- number
- Description
- Name
y- Type
- number
- Description
Example
if ui.is_menu_open() then
local x, y = ui.menu_position()
logger.info('Menu is at (%d, %d)', x, y)
end
functionui.menu_size()
menu_size
Returns the menu dimensions, regardless of whether the menu is open or not.
Returns
- Name
width- Type
- number
- Description
- Name
height- Type
- number
- Description
Example
if ui.is_menu_open() then
local x, y = ui.menu_size()
logger.info('Menu dimensions are (%d, %d)', x, y)
end
functionui.mouse_position()
mouse_position
Returns the mouse position.
Returns
- Name
x- Type
- number
- Description
- Name
y- Type
- number
- Description
Example
local mouse_x, mouse_y = ui.mouse_position()
logger.info('Mouse is at (%d, %d)', mouse_x, mouse_y)
functionui.get(ref)
get
Returns the value of the UI item in ref
Parameters
- Name
ref- Type
- number
- Description
Returns
- Name
value- Type
- any
- Description
- The return type is dependent on the type of the UI item
Example
local sld = ui.new_slider('Field of view', 0, 180, 84, true, '°', 1)
local val = ui.get(sld)
logger.info('%i', val)
functionui.set(ref, value)
set
Sets the value of the UI item in ref
Parameters
- Name
ref- Type
- number
- Description
- Name
value- Type
- any
- Description
- The value type is dependent on the type of the UI item
Example
local sld = ui.new_slider('Field of view', 0, 180, 84, true, '°', 1)
local val = ui.get(sld)
logger.info('%i', val)
ui.set(sld, 90)
val = ui.get(sld)
logger.info('%i', val)
functionui.set_callback(ref, callback)
set_callback
Sets a callback on the UI item in ref that's called when the item value is updated.
Parameters
- Name
ref- Type
- number
- Description
- Name
callback- Type
- function
- Description
Example
local txt = ui.new_textbox('Textbox')
ui.set_callback(txt, function()
logger.info('New value: %s', ui.get(txt))
end)
functionui.hide_item(ref)
hide_item
Hides the UI item in ref.
Parameters
- Name
ref- Type
- number
- Description
Example
local chk = ui.new_checkbox('Checkbox')
ui.hide_item(chk)
functionui.mouse_position()
show_item
Shows the UI item in ref.
Parameters
- Name
ref- Type
- number
- Description
Example
local chk = ui.new_checkbox('Checkbox')
ui.show_item(chk)
functionui.new_button(name, callback)
new_button
Creates a new button.
Parameters
- Name
name- Type
- string
- Description
- Name of the control
- Name
callback- Type
- function
- Description
- Callback function to be ran when your button is pressed
Returns
Example
local btn = ui.new_button('Test', function()
logger.info('I was pressed!')
end)
functionui.new_checkbox(name)
new_checkbox
Creates a new checkbox.
Parameters
- Name
name- Type
- string
- Description
- Name of the control
Returns
Example
local chk = ui.new_checkbox('Enabled')
functionui.new_colorpicker(name, [default_r], [default_g], [default_b], [default_a])
new_colorpicker
Creates a new color picker.
Parameters
- Name
name- Type
- string
- Description
- Name of the control
- Name
default_r- Type
- number
- Default value
- = 0
- Description
- Name
default_g- Type
- number
- Default value
- = 0
- Description
- Name
default_b- Type
- number
- Default value
- = 0
- Description
- Name
default_a- Type
- number
- Default value
- = 0
- Description
Returns
Example
local clr = ui.new_colorpicker('Color', 0x95, 0x80, 0xFF, 0xFF) -- #9580FFFF
functionui.new_combobox(name, ...items)
new_combobox
Creates a new combobox.
Parameters
- Name
name- Type
- string
- Description
- Name of the control
- Name
...items- Type
- string[]
- Description
- List of items
Returns
Example
local cbx = ui.new_combobox('Combobox', 'Item 1', 'Item 2')
functionui.new_hotkey(name, [default_hotkey])
new_hotkey
TODO: Creates a new hotkey.
Parameters
- Name
name- Type
- string
- Description
- Name of the control
- Name
default_hotkey- Type
- number
- Default value
- = 0
- Description
- TODO: Default hotkey
Returns
Example
local hk = ui.new_hotkey('Hotkey')
functionui.new_label(label)
new_label
Creates a new label.
Parameters
- Name
label- Type
- string
- Description
- Label
Returns
Example
local lbl = ui.new_label('Label')
functionui.new_listbox(name, ...items)
new_listbox
Creates a new listbox.
Parameters
- Name
name- Type
- string
- Description
- Name of the control
- Name
...items- Type
- string[]
- Description
- List of items
Returns
Example
local lst = ui.new_listbox('Listbox', 'Item 1', 'Item 2', 'Item 3', 'Item 4')
functionui.new_multiselect(name, ...items)
new_multiselect
Creates a new multiselect.
Parameters
- Name
name- Type
- string
- Description
- Name of the control
- Name
...items- Type
- string[]
- Description
- List of items
Returns
Example
local msl = ui.new_multiselect('Multiselect', 'Item 1', 'Item 2', 'Item 3')
functionui.new_slider(name, min, max, [default_value], [show_tooltip], [unit], [scale])
new_slider
Creates a new slider
Parameters
- Name
name- Type
- string
- Description
- Name of the control
- Name
min- Type
- number
- Description
- Name
max- Type
- number
- Description
- Name
default_value- Type
- number
- Default value
- = 0
- Description
- Name
show_tooltip- Type
- boolean
- Default value
- = false
- Description
- Whether to show a tooltip in the menu
- Name
unit- Type
- string
- Description
- Unit to display after the value
- Name
scale- Type
- number
- Description
- Scale the display value by this number (if the scale is 0.1 and the value is 100, the display value will be 10)
Returns
Example
local sld = ui.new_slider('Field of view', 0, 180, 84, true, '°', 1)
functionui.new_string(name)
new_string
Creates a new string control. These are not rendered in the menu but exist to write arbitrary values to the config.
Parameters
- Name
name- Type
- string
- Description
- Name of the config item
Returns
Example
local str = ui.new_string('Test')
functionui.new_textbox(name)
new_textbox
Creates a new text input.