Skip to content

Settings

Settings.Module declares controls for a script or a built-in feature. They appear in its Options window in the Lua window, and Save settings saves their values.

For a user script, use its file name without .lua as the module name: hello.lua uses Settings.Module("hello"), and a module entry named sample-status.main.lua uses Settings.Module("sample-status"). For a built-in feature, use its pack id.

The feature's checkbox already switches the script on and off, so a script needs no Enabled option of its own.

local options = Settings.Module("my-feature")
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.
SetGroup(name) No value Put the script under the main-menu heading name, an existing one such as Automation or a new one. See Main-menu group.
AddToggleKey(defaultKey) No value Set the key that switches the script on and off, until the player sets their own. See Declare options before the script runs.
AddTooltip(name, text) No value Show text when the pointer rests on an option added before it. An unknown option raises an error.
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. Without a fallback, see below.
GetFloat(name[, fallback]) Number Read a decimal value. Without a fallback, see below.
GetString(name[, fallback]) String Read a string. Without a fallback, see below.
GetKeybind(name[, fallback]) Integer Read a virtual-key value. Without a fallback, see below.
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.

GetInt, GetFloat, GetString and GetKeybind take the fallback as an option. With one, they return the stored value, or the fallback when the option has none; the stored value is not clamped, even outside the slider's range. Without one, they return the stored value (the Add* default unless the player or a Set* call changed it), and GetInt and GetFloat clamp it to the min, max a module's AddInt or AddFloat declared. Without a fallback, reading an option that was never added or set raises an error.

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("ShowRadius", true, "Show the search radius")
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()
    local showRadius = options:GetBool("ShowRadius", true)
    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. A player can bind a combo such as Ctrl + A: the value then carries modifier bits above the key (Ctrl 0x100, Shift 0x200, Alt 0x400), and IsKeyPressed reads it as down only while that key is held with exactly those modifiers. A plain key reads as down whatever modifiers are held, as before. Every keybind also appears under the feature's name in Settings > Hotkeys.

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

Declare options before the script runs

A script's options, keybinds included, normally exist only once the script has run. Put them in an options file and the host runs that file at start-up, before the script is switched on. Its keybinds then claim their saved keys, show in Settings > Hotkeys, and can be set while the script is off.

AddToggleKey in the options file gives the script an on/off key that works from start-up: pressing it loads the script, pressing it again unloads it. A key the player sets or clears in Settings > Hotkeys and saves replaces it. Declared in the script itself rather than the options file, the key takes effect only after the script first runs. If another feature already holds the key, the log says so and the script has no key until the player sets one.

Script Options file
scripts\hello.lua scripts\hello.options.lua
modules\sample-status\sample-status.main.lua modules\sample-status\options.lua
Built-in pack The manifest's options file

The file runs alone, in a Lua state that has only Settings and Key, so it can't call require or any other API. A module entry takes the same table with require("options"); a standalone script declares the same options again, which finds them already declared. If the file fails, the script's Options window says why.

-- hello.options.lua
local options = Settings.Module("hello")
options:AddToggleKey(Key.F6)
options:AddKeybind("MarkKey", 0, "Mark the selected unit")
return options

SetGroup files the script under a main-menu heading, like a tag. Use a built-in heading (Map and resources, Automation, Secondary features, Scripts, Advanced) or any new name. A new name becomes a heading of its own, placed after Automation. Without SetGroup, a user script sits under Scripts and a built-in secondary feature under Secondary features.

The group decides where the script appears once the player shows it in the main menu, and where it is listed in Settings > Main menu. The player can move it to another heading there; their choice wins. Call SetGroup in the options file so the heading is right before the script first runs.

-- hello.options.lua
local options = Settings.Module("hello")
options:SetGroup("Scouting")

Saving values

Save settings writes declared values, on/off states and hotkeys to %APPDATA%\WololoLabs\config.ini.

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.