UI Library
The UI library provides comprehensive tools for creating and managing graphical user interfaces.
UI Creation
ui.create(name, logoUrl)
Creates a new tab in the UI.
Parameters
name
- Name of the tablogoUrl
- URL or local path to the tab icon
Returns
Returns a Tab object
Tab:group(name)
Creates a new group within a tab.
Parameters
name
- Name of the group
Returns
Returns a Group object
ui.button(x, y, width, height, text, color, hoverColor, clickCallback, logoUrl)
Creates a standalone button not attached to any group.
Parameters
x
- X position of the buttony
- Y position of the buttonwidth
- Width of the buttonheight
- Height of the buttontext
- Button textcolor
- Button colorhoverColor
- Button color when hoveredclickCallback
- Function called when button is clickedlogoUrl
- Optional icon URL or path
Group Components
Group:switch(id, default)
Creates a switch/toggle component.
Parameters
name
- Identifier for the switchdefault
- Default state of the switch (Optional)
Returns
Returns a Switch object
Group:slider(id, min, max, default, decimals)
Creates a slider component.
Parameters
name
- Identifier for the slidermin
- Minimum value (Optional)max
- Maximum value (Optional)default
- Default value (Optional)decimals
- Number of decimal places (Optional)
Returns
Returns a Slider object
Group:input(id, max, default)
Creates an input field component.
Parameters
name
- Identifier for the inputmax
- Maximum length (Optional)default
- Default value (Optional)
Returns
Returns an Input object
Group:combo(id, items, default, multi)
Creates a combo box/dropdown component.
Parameters
name
- Identifier for the combo boxitems
- Array of items to display (Optional)default
- Default selected item (Optional)multi
- Enable multi-selection (Optional)
Returns
Returns a Combo object
Group:picker(id, default, alpha)
Creates a color picker component.
Parameters
name
- Identifier for the pickerdefault
- Default color (Optional)alpha
- Enable alpha channel selection (Optional)
Returns
Returns a Slider object
Group:button(id, callback)
Creates a button component.
Parameters
name
- Identifier for the buttoncallback
- Function to call when clicked (Optional)
Returns
Returns a Button object
Group:label(id, color)
Creates a text label component.
Parameters
name
- Identifier for the labelcolor
- Text color (Optional)
Returns
Returns a Label object
Global Group Methods
Group:visibility(visible)
Sets the visibility of the entire group.
Parameters
visible
- Boolean visibility state
Group:delete()
Removes the group and all its elements.
Global Element Methods
Element:tooltip(desc)
Adds a tooltip to any UI element.
Parameters
desc
- Tooltip text to display
Element:set_callback(callback)
Sets a callback function for the element.
Parameters
callback
- Function to call when the element is interacted with
Element:visibility(visible)
Sets the visibility of an element.
Parameters
visible
- Boolean visibility state
Element:active(value)
Sets the active state of an element.
Parameters
value
- Boolean active state
Element:delete()
Removes the element from the UI.
Element:get()
Gets the current value of the element.
Returns
Returns value of element
Element:set(value)
Sets the value of the element.
Parameters
value
- New value to set
Color Picker Methods
ColorPicker:updateSV(x, y)
Updates the saturation and value of the color picker.
Parameters
x
- Saturation value (0-1)y
- Value (0-1)
ColorPicker:updateHue(y)
Updates the hue of the color picker.
Parameters
y
- Hue value (0-1)
ColorPicker:updateAlpha(x)
Updates the alpha channel of the color picker.
Parameters
x
- Alpha value (0-1)
ColorPicker:HSVtoRGB(h, s, v)
Converts HSV color values to RGB.
Parameters
h
- Hue (0-360)s
- Saturation (0-1)v
- Value (0-1)
ColorPicker:getRGB()
Gets the current RGB values.
Returns
Returns color, alpha
ColorPicker:setRGB(color, a)
Sets the RGB values.
Parameters
color
- RGB color valuea
- Alpha value
ComboBox Methods
ComboBox:update(items)
Updates the items in the combo box.
Parameters
items
- New array of items to display
ComboBox:toggle()
Toggles the combo box open/closed state.
ComboBox:setOpen(value)
Sets the combo box open/closed state.
Parameters
value
- Boolean state to set
Label Methods
Label:setColor(color)
Sets the color of the label text.
Parameters
color
- New color value
Label:setText(text)
Sets the text content of the label.
Parameters
text
- New text content
Utility Functions
utils.notify(title, message)
Displays a notification.
Parameters
title
- Title of the notificationmessage
- Content of the notification
utils.console.show()
Shows the console window.
utils.console.hide()
Hides the console window.
utils.console.print(...)
Prints messages to the console.
Parameters
...
- Variable number of items to print
utils.round(number, decimals)
Rounds a number to specified decimal places.
Parameters
number
- Number to rounddecimals
- Number of decimal places
utils.random.test(amt)
Tests random number generation.
Parameters
amt
- Amount of tests to run
Returns
Returns a table with average, minimum, maximum, and sample
utils.random.number(min, max)
Generates a random number.
Parameters
min
- Minimum valuemax
- Maximum value
utils.random.boolean(probability)
Generates a random boolean.
Parameters
probability
- Probability of true (0-1)
utils.random.string(length, charset)
Generates a random string.
Parameters
length
- Length of the stringcharset
- Characters to use
utils.random.color(alpha)
Generates a random color.
Parameters
alpha
- Include alpha channel
utils.random.delay(min, max)
Sets a random delay.
Parameters
min
- Minimum delaymax
- Maximum delay
utils.random.gamble(table)
Returns a random item from a weighted probability table.
Parameters
table
- Table with items as keys and probabilities as values
local items = {
["rare item"] = 10, -- 10% chance
["common item"] = 60, -- 60% chance
["uncommon item"] = 30 -- 30% chance
}
local result = utils.random.gamble(items)
UI Management
ui.setSize(scale)
Resize menu and all its components.
Parameters
scale
- Scale factor to resize the UI
ui.cleanup()
Delete all elements, groups and tabs.
ui.close()
Close the window.
ui.minimize()
Minimize the window.
ui.init()
Initialize and start the UI. Must be called at the end of the script.