Skip to content

Settings

Settings.Module declares controls for a script or built-in micro-feature. For a user script, use its file name without .lua as the module name. The controls then appear below that script in the User scripts tab.

For example, hello.lua uses Settings.Module("hello"). A module entry named sample-status.main.lua uses Settings.Module("sample-status"). User-script values last for the current session, but Save config does not save them.

For a built-in micro-feature, use its feature identifier. Its controls appear below the matching feature in the Micro features tab and can be saved.

local options = Settings.Module("my-feature")
options:AddBool("Enabled", true, "Active")
options:AddInt("IntervalMs", 250, 50, 1000, "Interval (ms)")

Module API

Create one settings table at the top of a script or built-in feature. Its module name must match the script name or feature identifier described above.

Method Result Meaning
AddBool(name[, default = false[, label]]) No value Add a checkbox.
AddInt(name, default[, min, max[, label]]) No value Add an integer control.
AddFloat(name, default[, min, max[, label]]) No value Add a decimal control.
AddDropdown(name, default, choices[, label]) No value Add a string-choice control.
AddKeybind(name, defaultKey[, label]) No value Add a hotkey picker.
AddTooltip(...) No values Not implemented. Ignores arguments and logs a warning.
AddColor(name, defaultColor) No value Store an in-session color only.
GetBool(name[, fallback = false]) Boolean Read a boolean.
GetInt(name, fallback) Integer Read an integer.
GetFloat(name, fallback) Number Read a decimal value.
GetString(name, fallback) String Read a string.
GetKeybind(name, fallback) Integer Read a virtual-key value.
GetColor(name, fallbackColor) Color table Read an in-session color.
SetBool(name, value) No value Write a boolean.
SetInt(name, value) No value Write an integer.
SetFloat(name, value) No value Write a decimal value.
SetString(name, value) No value Write a string.

The Add* calls keep an existing value. They use the default only when the option has no value.

An integer or decimal control becomes a slider when you provide both bounds. A dropdown needs a non-empty dense array of strings.

Example

local options = Settings.Module("my-feature")

options:AddBool("Enabled", true, "Active")
options:AddInt("Radius", 12, 1, 64, "Search radius")
options:AddFloat("Weight", 0.5, 0.0, 1.0, "Priority weight")
options:AddDropdown("Mode", "safe", { "safe", "fast" }, "Mode")
options:AddKeybind("ToggleKey", 0, "Toggle key")

function Update()
    if options:GetBool("Enabled", true) ~= true then
        return
    end

    local radius = options:GetInt("Radius", 12)
    local mode = options:GetString("Mode", "safe")
    local key = options:GetKeybind("ToggleKey", 0)
end

A key of 0 means that no key is bound. Use Key constants from the enum index for common key values.

IsKeyPressed(virtualKey) stays true while the key stays down. Save the previous value when one action must happen for each key press.

local previous_down = false

function pressed_once(key)
    local down = key > 0 and IsKeyPressed(key) == true
    local pressed = down and not previous_down
    previous_down = down
    return pressed
end

Saving built-in feature values

The Save config and Load config controls save and restore declared built-in feature values in %APPDATA%\WololoLabs\config.ini.

The feature checkbox lasts only for the current session. Add an Enabled option when a built-in feature needs a saved active state.

AddColor does not create a panel control or a saved value. There is no AddString method. Use SetString and GetString only for feature state.

Legacy global form

The global Settings table also has add, get, and set functions for older scripts. New built-in features must use the module table. The global form does not create a settings panel or saved values.

Settings.AddTooltip(...) is also not implemented.