Switch
The switch UI element allows users to add a toggle button to their mods. This can be used, for example, to enable or disable a particular feature or setting.
To add a switch UI element to your mod, use the utils.addSwitch
function. This function takes the following parameters:
utils.addSwitch(section, key, title, defaultValue, description)
section
: The section to add the switch to.key
: A unique key to identify the switch.title
: The title of the switch.defaultValue
: The default value of the switch.description
: A description of the switch (optional).
Here's an example of how to add a switch that enables god mode:
local section = utils.addSection(mainView, "God Mode", "Enable or disable god mode")
utils.addSwitch(section, "godModeSwitch", "God Mode", 1, "Enabling this will make your character invincible")
You can then use the isSwitchOn
function to check whether the switch is turned on or off:
if isSwitchOn("godModeSwitch") then
-- Enable god mode
else
-- Disable god mode
end
Last updated