gui
Info
If you need to get a container ID or an existing control ID, enable SCRIPTS > General > Debug mode and hover on a groupbox or any element.
Info
You can stack most control in line with other controls. To do that, pass the ID of a control that already exists into the container_id
argument of the function.
is_menu_open
gui.is_menu_open()
-> bool
Returns true if the menu window is open.
Usage
if gui.is_menu_open() then
-- ...
end
get_menu_rect
gui.get_menu_rect()
-> number, number, number, number
Returns menu window rectangle.
Usage
local x1, y1, x2, y2 = gui.get_menu_rect();
checkbox
gui.checkbox(id: string, container_id: string, label: string)
-> checkbox
Creates a new checkbox.
Parameters
Name | Type | Description |
---|---|---|
id |
string | ID |
container_id |
string | Container ID |
label |
string | Label |
Usage
local item = gui.checkbox('scripts.elements_a.test', 'scripts.elements_a', 'My item');
get_checkbox
gui.get_checkbox(id: string)
-> checkbox
Returns an existing checkbox or nil
if not found.
Parameters
Name | Type | Description |
---|---|---|
id |
string | ID |
Usage
local item = gui.get_checkbox('scripts.elements_a.test');
slider
gui.slider(id: string, container_id: string, label: string, min: number, max: number, format: string = '%.0f', step: number = 1.0)
-> slider
Creates a new slider.
Note
Format argument documentation: here
Parameters
Name | Type | Description |
---|---|---|
id |
string | ID |
container_id |
string | Container ID |
label |
string | Label |
min |
number | Minimal value |
max |
number | Maximal value |
format |
string | Display format. Defaults to %.0f |
step |
number | Step value. Defaults to 1.0 |
Usage
local item = gui.slider('scripts.elements_a.test', 'scripts.elements_a', 'My item', 0, 100);
get_slider
gui.get_slider(id: string)
-> slider
Returns an existing slider or nil
if not found.
Parameters
Name | Type | Description |
---|---|---|
id |
string | ID |
Usage
local item = gui.get_slider('scripts.elements_a.test');
combobox
gui.combobox(id: string, container_id: string, label: string, values: string...)
-> combobox
Creates a new combobox.
Parameters
Name | Type | Description |
---|---|---|
id |
string | ID |
container_id |
string | Container ID |
label |
string | Label |
values |
string... | Items |
Usage
local item = gui.combobox('scripts.elements_a.test', 'scripts.elements_a', 'My item', 'Item 1', 'Item 2', 'Item 3');
combobox
gui.combobox(id: string, container_id: string, label: string, is_multi: bool, values: string...)
-> combobox
Creates a new (multiselect-)combobox.
Parameters
Name | Type | Description |
---|---|---|
id |
string | ID |
container_id |
string | Container ID |
label |
string | Label |
is_multi |
bool | Determines if this combobox should act as a multiselect |
values |
string... | Items |
Usage
local item = gui.combobox('scripts.elements_a.test', 'scripts.elements_a', 'My item', true, 'Item 1', 'Item 2', 'Item 3');
get_combobox
gui.get_combobox(id: string)
-> combobox
Returns an existing combobox or nil
if not found.
Parameters
Name | Type | Description |
---|---|---|
id |
string | ID |
Usage
local item = gui.get_combobox('scripts.elements_a.test');
button
gui.button(id: string, container_id: string, label: string)
-> button
Creates a new button.
Parameters
Name | Type | Description |
---|---|---|
id |
string | ID |
container_id |
string | Container ID |
label |
string | Label |
Usage
local item = gui.button('scripts.elements_a.test', 'scripts.elements_a', 'My item');
get_button
gui.get_button(id: string)
-> button
Returns an existing button or nil
if not found.
Parameters
Name | Type | Description |
---|---|---|
id |
string | ID |
Usage
local item = gui.get_button('scripts.elements_a.test');
label
gui.label(id: string, container_id: string, label: string)
-> label
Creates a new label.
Parameters
Name | Type | Description |
---|---|---|
id |
string | ID |
container_id |
string | Container ID |
label |
string | Label |
Usage
local item = gui.label('scripts.elements_a.test', 'scripts.elements_a', 'My item');
get_label
gui.get_label(id: string)
-> label
Returns an existing label or nil
if not found.
Parameters
Name | Type | Description |
---|---|---|
id |
string | ID |
Usage
local item = gui.get_label('scripts.elements_a.test');
textbox
gui.textbox(id: string, container_id: string)
-> textbox
Creates a new textbox.
Parameters
Name | Type | Description |
---|---|---|
id |
string | ID |
container_id |
string | Container ID |
Usage
local item = gui.textbox('scripts.elements_a.test', 'scripts.elements_a');
get_textbox
gui.get_textbox(id: string)
-> textbox
Returns an existing textbox or nil
if not found.
Parameters
Name | Type | Description |
---|---|---|
id |
string | ID |
Usage
local item = gui.get_textbox('scripts.elements_a.test');
color_picker
gui.color_picker(id: string, container_id: string, label: string, default: table, allow_alpha: bool = true)
-> color_picker
Creates a new color picker.
Parameters
Name | Type | Description |
---|---|---|
id |
string | ID |
container_id |
string | Container ID |
label |
string | Label |
default |
table | Default color |
allow_alpha |
bool | Determines whether this item should allow alpha modification. Defaults to true |
Usage
local item = gui.color_picker('scripts.elements_a.test', 'scripts.elements_a', 'My item', render.color('#fff'));
get_color_picker
gui.get_color_picker(id: string)
-> color_picker
Returns an existing color picker or nil
if not found.
Parameters
Name | Type | Description |
---|---|---|
id |
string | ID |
Usage
local item = gui.get_color_picker('scripts.elements_a.test');
for_each_hotkey
gui.for_each_hotkey(fn: (string, number, number, bool))
Loops through all bound keys.
Callback parameters
| Name | Type | Description |
| ---- | ---- | ----------- |
| name
| string | Item name |
| key
| number | Active key (documentation) |
| mode
| enum | Hotkey mode |
| is_active
| bool | True if currently active |
Parameters
Name | Type | Description |
---|---|---|
fn |
function(string, number, number, bool) | Callback function |
Usage
gui.for_each_hotkey(function (name, key, mode, is_active)
print('Hotkey ' .. name .. ':');
print('\tkey = ' .. tostring(key));
print('\tmode = ' .. tostring(mode));
print('\tis_active = ' .. tostring(is_active));
end);
add_notification
gui.add_notification(title: string, message: string)
Adds a new notification.
Parameters
Name | Type | Description |
---|---|---|
title |
string | Title |
message |
string | Message |
Usage
gui.add_notification('Hello', 'This lua was loaded!');
show_message
gui.show_message(id: string, title: string, message: string)
Shows a message box.
Note
Message contents will be automatically wrapped and centered.
Parameters
Name | Type | Description |
---|---|---|
id |
string | Message box ID |
title |
string | Title |
message |
string | Message |
Usage
gui.show_message('my_message', 'Hello!', 'Click OK to close this message.');
show_dialog
gui.show_dialog(id: string, title: string, message: string, buttons: enum, callback: (enum))
Shows a dialog box.
Note
Message contents will be automatically wrapped and centered.
Parameters
Name | Type | Description |
---|---|---|
id |
string | Message box ID |
title |
string | Title |
message |
string | Message |
button |
enum | Dialog box buttons |
callback |
function(enum) | Result callback |
Usage
gui.show_dialog('my_dialog', 'Hello!', 'Do you like cats?', gui.dialog_buttons_yes_no, function (res)
if res == gui.dialog_result_affirmative then
gui.show_message('my_message', 'Hey!', 'Me too ^^');
else
gui.show_message('my_message', ':(', 'What about otters?');
end
end);