GUI

Build custom interfaces with tabs, panels, and interactive elements like checkboxes, sliders, and buttons.

Tab and Panel Creation

gui.get_tab

Signature: gui.get_tab(name)

Description: Retrieves a predefined tab by name.

Parameters:

  • name (string): The name of the tab to retrieve. Valid values are "aimbot", "visuals", "lua", and "settings".

Returns:

  • tab (object): A tab object that can be used to create panels and subtabs.

Example:

-- Get the "lua" tab
local lua_tab = gui.get_tab("lua")

-- Get the "visuals" tab
local visuals_tab = gui.get_tab("visuals")

tab:create_panel

Signature: tab:create_panel(label, small_panel?)

Description: Creates a panel inside a tab.

Parameters:

  • label (string): The title of the panel.

  • small_panel (boolean, optional): Whether to create a small panel. Defaults to false.

Returns:

  • panel (object): A panel object that can be used to add UI elements.

Example:

-- Get the lua tab and create a panel
local lua_tab = gui.get_tab("lua")
local my_panel = lua_tab:create_panel("My Script Settings")

-- Create a small panel for compact UI
local compact_panel = lua_tab:create_panel("Quick Settings", true)

tab:create_subtab

Signature: tab:create_subtab(label)

Description: Creates a subtab inside a tab.

Parameters:

  • label (string): The title of the subtab.

Returns:

  • subtab (object): A subtab object that can be used to create panels.

Example:

-- Get the visuals tab and create subtabs for different categories
local visuals_tab = gui.get_tab("visuals")
local player_subtab = visuals_tab:create_subtab("Player")
local world_subtab = visuals_tab:create_subtab("World")
local misc_subtab = visuals_tab:create_subtab("Misc")

subtab:create_panel

Signature: subtab:create_panel(label, small_panel?)

Description: Creates a panel inside a subtab.

Parameters:

  • label (string): The title of the panel.

  • small_panel (boolean, optional): Whether to create a small panel. Defaults to false.

Returns:

  • panel (object): A panel object that can be used to add UI elements.

Example:

-- Get the lua tab, create a subtab, and then create panels in the subtab
local lua_tab = gui.get_tab("lua")
local features_subtab = lua_tab:create_subtab("Features")

-- Create panels in the subtab
local main_panel = features_subtab:create_panel("Main Features")
local extra_panel = features_subtab:create_panel("Extra Features", true)

Panel Widgets

panel:add_checkbox

Signature: panel:add_checkbox(label)

Description: Adds a checkbox to the panel.

Parameters:

  • label (string): The label for the checkbox.

Returns:

  • checkbox (object): A checkbox object with methods to get and set its state.

Example:

-- Create a checkbox
local panel = gui.get_tab("lua"):create_panel("Settings")
local enable_feature = panel:add_checkbox("Enable Feature")

-- Get and set checkbox state
local is_enabled = enable_feature:get()  -- Get current state (true/false)
enable_feature:set(true)  -- Set the checkbox to checked

panel:add_slider_int

Signature: panel:add_slider_int(label, min, max, default)

Description: Adds an integer slider to the panel.

Parameters:

  • label (string): The label for the slider.

  • min (number): The minimum value for the slider.

  • max (number): The maximum value for the slider.

  • default (number): The default value for the slider.

Returns:

  • slider_int (object): A slider object with methods to get and set its value.

Example:

-- Create an integer slider
local panel = gui.get_tab("lua"):create_panel("Settings")
local damage_slider = panel:add_slider_int("Damage", 0, 100, 50)

-- Get and set slider value
local current_damage = damage_slider:get()  -- Get current value (0-100)
damage_slider:set(75)  -- Set the slider to 75

panel:add_slider_float

Signature: panel:add_slider_float(label, min, max, default)

Description: Adds a floating-point slider to the panel.

Parameters:

  • label (string): The label for the slider.

  • min (number): The minimum value for the slider.

  • max (number): The maximum value for the slider.

  • default (number): The default value for the slider.

Returns:

  • slider_float (object): A slider object with methods to get and set its value.

Example:

-- Create a float slider
local panel = gui.get_tab("lua"):create_panel("Settings")
local scale_slider = panel:add_slider_float("Scale", 0.1, 2.0, 1.0)

-- Get and set slider value
local current_scale = scale_slider:get()  -- Get current value (0.1-2.0)
scale_slider:set(1.5)  -- Set the slider to 1.5

panel:add_button

Signature: panel:add_button(label, function)

Description: Adds a button to the panel with a callback function that will be executed when the button is clicked.

Parameters:

  • label (string): The label for the button.

  • function (function): The callback function to execute when the button is clicked.

Returns:

  • button (object): A button object.

Example:

-- Create a button with a callback
local panel = gui.get_tab("lua"):create_panel("Actions")
local apply_button = panel:add_button("Apply Changes", function()
    engine.log("Button clicked! Applying changes...", 0, 255, 0, 255)
    -- Perform actions when button is clicked
    -- Example: Save settings, apply configuration, etc.
end)

panel:add_text

Signature: panel:add_text(label)

Description: Adds a static text label to the panel.

Parameters:

  • label (string): The text to display.

Returns:

  • text (object): A text object with methods to get and set its content.

Example:

-- Create a text label
local panel = gui.get_tab("lua"):create_panel("Information")
local info_text = panel:add_text("This script enhances gameplay with custom features")

-- Get and set text
local current_text = info_text:get()  -- Get current text
info_text:set("Updated information: Version 2.0")  -- Set new text

panel:add_input_text

Signature: panel:add_input_text(label, default)

Description: Adds a text input box to the panel.

Parameters:

  • label (string): The label for the input box.

  • default (string): The default text for the input box.

Returns:

  • input_text (object): An input text object with methods to get and set its value.

Example:

-- Create a text input box
local panel = gui.get_tab("lua"):create_panel("Configuration")
local username_input = panel:add_input_text("Username", "Player")

-- Get and set input value
local current_username = username_input:get()  -- Get current text
username_input:set("Pro_Player123")  -- Set new text

panel:add_color_picker

Signature: panel:add_color_picker(label, r, g, b, a)

Description: Adds a color picker to the panel.

Parameters:

  • label (string): The label for the color picker.

  • r (number): The default red component (0-255).

  • g (number): The default green component (0-255).

  • b (number): The default blue component (0-255).

  • a (number): The default alpha component (0-255).

Returns:

  • color_picker (object): A color picker object with methods to get and set its color.

Example:

-- Create a color picker
local panel = gui.get_tab("visuals"):create_panel("Colors")
local highlight_color = panel:add_color_picker("Highlight Color", 255, 0, 0, 255)  -- Red by default

-- Get current color
local r, g, b, a = highlight_color:get()
engine.log("Current color: R=" .. r .. ", G=" .. g .. ", B=" .. b .. ", A=" .. a, r, g, b, a)

-- Set a new color (green)
highlight_color:set(0, 255, 0, 255)

panel:add_keybind

Signature: panel:add_keybind(label, key, mode)

Description: Adds a keybind to the panel.

Parameters:

  • label (string): The label for the keybind.

  • key (number): The default key code.

  • mode (number): The keybind mode (see key_mode constants).

Returns:

  • keybind (object): A keybind object with methods to get and set its key and mode.

Example:

-- Create a keybind with toggle mode
local panel = gui.get_tab("lua"):create_panel("Hotkeys")
local feature_key = panel:add_keybind("Feature Toggle", 70, key_mode.toggle)  -- Key 'F' with toggle mode

-- Get current key and mode
local key = feature_key:get_key()  -- Get current key code
local mode = feature_key:get_mode()  -- Get current mode
local active = feature_key:is_active()  -- Check if keybind is active

-- Set new key and mode
feature_key:set_key(71)  -- Set to key 'G'
feature_key:set_mode(key_mode.onhotkey)  -- Change to on-hotkey mode

panel:add_single_select

Signature: panel:add_single_select(label, list, default_index?)

Description: Adds a single-select dropdown to the panel.

Parameters:

  • label (string): The label for the dropdown.

  • list (table): A table of string options.

  • default_index (number, optional): The default selected index (0).

Returns:

  • single_select (object): A single-select object with methods to get and set the selected index.

Example:

-- Create a single-select dropdown
local panel = gui.get_tab("lua"):create_panel("Options")
local weapon_select = panel:add_single_select("Weapon", {"Rifle", "Pistol", "Shotgun", "Sniper"}, 1)

-- Get current selection
local selected_index = weapon_select:get()  -- Get selected index (0-3)
local selected_weapon = {"Rifle", "Pistol", "Shotgun", "Sniper"}[selected_index]
engine.log("Selected weapon: " .. selected_weapon, 255, 255, 255, 255)

-- Set new selection
weapon_select:set(3)  -- Select "Shotgun" (index 3)

panel:add_multi_select

Signature: panel:add_multi_select(label, list)

Description: Adds a multi-select list to the panel.

Parameters:

  • label (string): The label for the multi-select list.

  • list (table): A table of string options.

Returns:

  • multi_select (object): A multi-select object with methods to get and set the state of individual items.

Example:

-- Create a multi-select list
local panel = gui.get_tab("lua"):create_panel("Features")
local active_features = panel:add_multi_select("Active Features", {"ESP", "Aimbot", "Triggerbot", "Radar"})

-- Set initial selections
active_features:set(1, true)  -- Enable "ESP" (index 1)
active_features:set(3, true)  -- Enable "Triggerbot" (index 3)

-- Check if specific options are selected
if active_features:get(1) then  -- Check if "ESP" is selected
    engine.log("ESP is enabled", 0, 255, 0, 255)
end

if active_features:get(2) then  -- Check if "Aimbot" is selected
    -- Aimbot functionality
end

panel:add_singleselect_list

Signature: panel:add_singleselect_list(label, list)

Description: Adds a single-select list (not dropdown) to the panel.

Parameters:

  • label (string): The label for the list.

  • list (table): A table of string options.

Returns:

  • input_list_single (object): A single-select list object with methods to get and set the selected index.

Example:

-- Create a single-select list
local panel = gui.get_tab("lua"):create_panel("Configuration")
local mode_list = panel:add_singleselect_list("Game Mode", {"Casual", "Competitive", "Deathmatch", "Training"})

-- Set default selection
mode_list:set(2)  -- Select "Competitive" (index 2)

-- Get current selection
local selected_mode_index = mode_list:get()
local modes = {"Casual", "Competitive", "Deathmatch", "Training"}
engine.log("Selected mode: " .. modes[selected_mode_index], 255, 255, 255, 255)

panel:add_multiselect_list

Signature: panel:add_multiselect_list(label, list)

Description: Adds a multi-select list (not dropdown) to the panel.

Parameters:

  • label (string): The label for the list.

  • list (table): A table of string options.

Returns:

  • input_list_multi (object): A multi-select list object with methods to get and set the state of individual items.

Example:

-- Create a multi-select list
local panel = gui.get_tab("lua"):create_panel("Configurations")
local target_list = panel:add_multiselect_list("Target Types", {"Players", "Bots", "Friends", "Enemies", "Teammates"})

-- Set initial selections
target_list:set(1, true)  -- Enable "Players" (index 1)
target_list:set(2, true)  -- Enable "Bots" (index 2)
target_list:set(4, true)  -- Enable "Enemies" (index 4)

-- Check if specific options are selected
if target_list:get(1) and target_list:get(4) then
    engine.log("Both Players and Enemies are targeted", 255, 255, 0, 255)
end

Element Control

element:set_active

Signature: element:set_active(bool)

Description: Shows or hides any GUI element.

Parameters:

  • bool (boolean): true to show the element, false to hide it.

Returns: None

Example:

-- Create some UI elements
local panel = gui.get_tab("lua"):create_panel("Dynamic UI")
local enable_advanced = panel:add_checkbox("Show Advanced Options")
local advanced_slider = panel:add_slider_int("Advanced Setting", 0, 100, 50)

-- Hide the advanced slider initially
advanced_slider:set_active(false)

-- Create a function to toggle visibility based on checkbox
engine.register_on_engine_tick(function()
    -- Show/hide advanced slider based on checkbox state
    if enable_advanced:get() then
        advanced_slider:set_active(true)
    else
        advanced_slider:set_active(false)
    end
end)

Checkbox Methods

checkbox:get

Signature: checkbox:get()

Description: Gets the current state of a checkbox.

Parameters: None

Returns:

  • boolean: true if checked, false otherwise.


checkbox:set

Signature: checkbox:set(bool)

Description: Sets the state of a checkbox.

Parameters:

  • bool (boolean): true to check, false to uncheck.

Returns: None


Slider Methods

slider_int:get / slider_float:get

Signature: slider_int:get() / slider_float:get()

Description: Gets the current value of a slider.

Parameters: None

Returns:

  • number: The current slider value.


slider_int:set / slider_float:set

Signature: slider_int:set(value) / slider_float:set(value)

Description: Sets the value of a slider.

Parameters:

  • value (number): The new value for the slider.

Returns: None


Text Methods

text:get

Signature: text:get()

Description: Gets the current text of a text label.

Parameters: None

Returns:

  • string: The current text.


text:set

Signature: text:set(str)

Description: Sets the text of a text label.

Parameters:

  • str (string): The new text.

Returns: None


Input Text Methods

input_text:get

Signature: input_text:get()

Description: Gets the current text from an input text field.

Parameters: None

Returns:

  • string: The current input text.


input_text:set

Signature: input_text:set(str)

Description: Sets the text of an input text field.

Parameters:

  • str (string): The new text.

Returns: None


Color Picker Methods

color_picker:get

Signature: color_picker:get()

Description: Gets the current RGBA color values from a color picker.

Parameters: None

Returns:

  • r, g, b, a (numbers): The red, green, blue, and alpha components (0-255).


color_picker:set

Signature: color_picker:set(r, g, b, a)

Description: Sets the RGBA color of a color picker.

Parameters:

  • r (number): The red component (0-255).

  • g (number): The green component (0-255).

  • b (number): The blue component (0-255).

  • a (number): The alpha component (0-255).

Returns: None


Keybind Methods

keybind:get_key

Signature: keybind:get_key()

Description: Gets the current key code of a keybind.

Parameters: None

Returns:

  • number: The virtual key code.


keybind:set_key

Signature: keybind:set_key(k)

Description: Sets the key code of a keybind.

Parameters:

  • k (number): The virtual key code.

Returns: None


keybind:get_mode

Signature: keybind:get_mode()

Description: Gets the current mode of a keybind.

Parameters: None

Returns:

  • number: The keybind mode (see key_mode constants).


keybind:set_mode

Signature: keybind:set_mode(mode)

Description: Sets the mode of a keybind.

Parameters:

  • mode (number): The keybind mode (see key_mode constants).

Returns: None


keybind:is_active

Signature: keybind:is_active()

Description: Checks if a keybind is currently active.

Parameters: None

Returns:

  • boolean: true if the keybind is active, false otherwise.


Select Methods

single_select:get

Signature: single_select:get()

Description: Gets the currently selected index from a single-select dropdown.

Parameters: None

Returns:

  • number: The selected index (1-based).


single_select:set

Signature: single_select:set(index)

Description: Sets the selected index of a single-select dropdown.

Parameters:

  • index (number): The index to select (1-based).

Returns: None


multi_select:get

Signature: multi_select:get(index)

Description: Gets the state of a specific item in a multi-select list.

Parameters:

  • index (number): The index of the item to check (1-based).

Returns:

  • boolean: true if the item is selected, false otherwise.


multi_select:set

Signature: multi_select:set(index, bool)

Description: Sets the state of a specific item in a multi-select list.

Parameters:

  • index (number): The index of the item to set (1-based).

  • bool (boolean): true to select the item, false to deselect it.

Returns: None


GUI State Management

gui.get_state

Signature: gui.get_state()

Description: Serializes the current GUI state to a Base64 string.

Parameters: None

Returns:

  • string: A Base64-encoded string representing the GUI state.

Example:

-- Save the current GUI state
local state_string = gui.get_state()
fs.write_to_file("gui_state.cfg", state_string)
engine.log("GUI state saved", 0, 255, 0, 255)

gui.load_state

Signature: gui.load_state(string)

Description: Loads a GUI state from a Base64 string.

Parameters:

  • string (string): A Base64-encoded state string previously obtained from gui.get_state().

Returns:

  • boolean: true if the state was loaded successfully, false otherwise.

Example:

-- Load a saved GUI state
if fs.does_file_exist("gui_state.cfg") then
    local state_string = fs.read_from_file("gui_state.cfg")
    if state_string then
        local success = gui.load_state(state_string)
        if success then
            engine.log("GUI state loaded", 0, 255, 0, 255)
        else
            engine.log("Failed to load GUI state", 255, 0, 0, 255)
        end
    end
end

Keybind Mode Constants

The following constants are used with keybind modes:

  • key_mode.onhotkey - Active while the key is held down

  • key_mode.offhotkey - Active while the key is not held down

  • key_mode.toggle - Toggles between active and inactive states when the key is pressed

  • key_mode.singlepress - Active for one frame when the key is pressed

  • key_mode.always_on - Always active, regardless of key state

Example:

-- Create keybinds with different modes
local panel = gui.get_tab("lua"):create_panel("Keybind Examples")

local toggle_key = panel:add_keybind("Toggle Feature", 84, key_mode.toggle)  -- 'T' key
local hold_key = panel:add_keybind("Hold Feature", 72, key_mode.onhotkey)    -- 'H' key
local single_key = panel:add_keybind("Single Press", 80, key_mode.singlepress)  -- 'P' key
local always_key = panel:add_keybind("Always On", 0, key_mode.always_on)

-- Check keybind states in the game loop
engine.register_on_engine_tick(function()
    if toggle_key:is_active() then
        -- Do something when toggle key is active
    end
    
    if hold_key:is_active() then
        -- Do something while hold key is pressed down
    end
    
    if single_key:is_active() then
        -- Do something on a single press (one frame only)
    end
    
    -- always_key will always return true for is_active()
end)

Last updated

Was this helpful?