ui

The ui library provides a powerful interface for Lua scripts to create, manage, and interact with native menu elements. This allows you to build custom configuration windows for your scripts.

Core Functions

These functions are used to interact with existing UI elements.

ui.getValue

Retrieves the current value of a specified UI widget.

value = ui.getValue(tab_ref, container_ref, name)

Parameters

  • tab_ref (string): The reference name of the tab the widget is in.

  • container_reef (string): The reference name of the container the widget is in.

  • name (string): The name of the widget.

Returns

  • The current value of the widget. The type of the value depends on the widget (e.g., boolean for a checkbox, number for a slider, string for an input text). Returns nil if the widget is not found.

ui.setValue

Sets a new value for a specified UI widget.

ui.setValue(tab_ref, container_ref, name, new_value)

Parameters

  • tab_ref, container_ref, name: (string) - Identifiers for the target widget.

  • new_value (any): The new value to set. The type must match what the widget expects (e.g., boolean for a checkbox, number for a slider).

-- Turn a checkbox off
ui.setValue("Aimbot", "Aimbot", "Enabled", false)

-- Set a slider's value
ui.setValue("Aimbot", "Aimbot", "Smoothing", 95.5)

-- Set a color picker's value using a table
ui.setValue("Visuals", "Visuals", "Box Color", {r=255, g=0, b=0, a=255})

ui.setVisibility

Shows or hides a specific UI widget.

ui.setVisibility(tab_ref, container_ref, name, is_visible)

Parameters

  • tab_ref, container_ref, name: (string) - Identifiers for the target widget.

  • is_visible (boolean): true to show the widget, false to hide it.

-- Hide the smoothing slider if the aimbot is disabled
local aimbot_enabled = ui.getValue("Aimbot", "Aimbot", "Enabled")
ui.setVisibility("Aimbot", "Aimbot", "Smoothing", aimbot_enabled)

Layout Elements

These functions create the main structure of your UI.

ui.newTab

Creates a new top-level tab in the menu.

ui.newTab(tab_ref, display_name)

Parameters

  • tab_ref (string): A unique reference name for this tab (e.g., "my_script_tab").

  • display_name (string): The text that will be displayed on the tab button (e.g., "My Script").

ui.newTab("my_script_main", "My Awesome Script")

ui.newContainer

Creates a new container (a column) within a specified tab. All widgets must be placed inside a container.

ui.newContainer(tab_ref, container_ref, display_name, [options])

Parameters

  • tab_ref (string): The reference name of the parent tab.

  • container_ref (string): A unique reference name for this container.

  • display_name (string): The title displayed at the top of the container.

  • options (table, optional): A table of boolean flags to control layout:

    • autosize (boolean): If true, the container's height will dynamically adjust to fit its content.

    • next (boolean): If true, will make the next container get placed in the right column

    • halfsize (boolean): If true, the container will take up half the width of a column (allowing for side-by-side containers).

    • visible (boolean): Defaults to true. Set to false to create a hidden container.

-- Create a full-height container in the left column
ui.newContainer("my_script_main", "my_script_visuals", "Visuals")

-- Create a second, auto-sizing container in the right column
ui.newContainer("my_script_main", "my_script_misc", "Misc", { autosize = true, next = true })

UI Widgets

These are the interactive elements you can add to a container.

ui.newCheckbox

Creates a standard checkbox.

  • Value Type: boolean

ui.newCheckbox(tab_ref, container_ref, name, [in_line])

Parameters

  • tab_ref, container_ref, name: (string) - Identifiers.

  • in_line (boolean, optional): If true, this checkbox will attempt to render on the same line as the previous element (useful for settings buttons).

ui.newSliderInt

Creates a slider for integer values.

  • Value Type: number (integer)

Signature

ui.newSliderInt(tab_ref, container_ref, name, min, max, [default])

Parameters

  • min, max (number): The minimum and maximum values for the slider.

  • default (number, optional): The initial value of the slider. Defaults to min.

ui.newSliderFloat

Creates a slider for floating-point (decimal) values.

  • Value Type: number (float)

Signature

ui.newSliderFloat(tab_ref, container_ref, name, min, max, [default])

ui.newDropdown

Creates a dropdown menu for selecting one option from a list.

  • Value Type: number (integer, 1-based index of the selected option)

ui.newDropdown(tab_ref, container_ref, name, options_table, [default_index])

Parameters

  • options_table (table): An array of strings representing the options.

  • default_index (number, optional): The 1-based index of the option to be selected initially. Defaults to 1.

ui.newMultiselect

Creates a dropdown menu where multiple options can be selected at once.

  • Value Type: table (an array of booleans)

ui.newMultiselect(tab_ref, container_ref, name, options_table)

ui.newColorpicker

Creates an interactive color picker.

  • Value Type: table (e.g., {r=255, g=128, b=0, a=255})

ui.newColorpicker(tab_ref, container_ref, name, [default_color], [in_line])

Parameters

  • default_color (table, optional): A table with r, g, b, and a keys (0-255).

  • in_line (boolean, optional): If true, attempts to render on the same line.

ui.newInputText

Creates a text input field.

  • Value Type: string

ui.newInputText(tab_ref, container_ref, name, [default_text])

ui.newButton

Creates a clickable button that executes a Lua function.

ui.newButton(tab_ref, container_ref, name, callback_function)

Parameters

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

ui.newListbox

Creates a listbox for selecting an item from a vertical list.

ui.newListbox(tab_ref, container_ref, name, options_table, [callback_function])

Parameters

  • options_table (table): An array of strings to display in the list.

  • callback_function (function, optional): A Lua function that is executed whenever a new item is selected.


Full Script Example

This example creates a new tab with two containers and populates them with various UI elements.

-- Create the main tab for our script
ui.newTab("my_script_tab", "My ESP Script")

-- Create a container for the main ESP settings in the left column, next makes the next container go to the right column
ui.newContainer("my_script_tab", "esp_settings", "ESP Settings", { autosize = true, next = true })

-- Add widgets to the first container
ui.newCheckbox("my_script_tab", "esp_settings", "Enable ESP")
ui.newSliderFloat("my_script_tab", "esp_settings", "Max Distance", 100.0, 2000.0, 500.0)
ui.newDropdown("my_script_tab", "esp_settings", "Box Style", { "Normal", "Cornered", "3D" }, 1)
ui.newMultiselect("my_script_tab", "esp_settings", "Flags", { "Health", "Distance", "Weapon" })
ui.newColorpicker("my_script_tab", "esp_settings", "Box Color", {r=0, g=255, b=255, a=255})

ui.newContainer("my_script_tab", "misc_settings", "Misc", { autosize = true })

-- Add widgets to the second container
ui.newInputText("my_script_tab", "misc_settings", "Custom Message", "Hello, World!")

local function on_button_click()
    -- Use ui.getValue to make the UI interactive
    local is_enabled = ui.getValue("my_script_tab", "esp_settings", "Enable ESP")
    local message = ui.getValue("my_script_tab", "misc_settings", "Custom Message")
    
    if is_enabled then
        print("Button Clicked! Your message is: " .. message)
    else
        print("Button Clicked, but the ESP is disabled!")
    end
end

ui.newButton("my_script_tab", "misc_settings", "Print Message", on_button_click)

print("My custom UI script has been loaded!")

Last updated