Skip to content

Script Structure

Required Globals

Every script must define these globals:

lua
name = "MyHero"              -- display name (string)
id = hero_id.abrams          -- which hero this script runs for

function is_enabled()
    return true              -- return true when the script should be active
end

function on_tick()
    -- your logic here
end

Settings Table

Define a settings table to expose configurable options in the UI:

lua
settings = {
    { key = "enabled",    type = "bool",      default = false,       label = "Enabled" },
    { key = "fov",        type = "float",     default = 5.0,         label = "Max FOV",  min = 1.0, max = 15.0 },
    { key = "delay",      type = "int",       default = 100,         label = "Delay ms", min = 0,   max = 1000 },
    { key = "hotkey",     type = "keybind",   default = VK.XBUTTON2, label = "Hotkey" },
    { key = "mode",       type = "combo",     default = 0,           label = "Mode", options = { "Hold Key", "Always On" } },
    { key = "slot",       type = "item_slot", default = 0,           label = "Item Slot" },
}

TIP

settings defines the UI layout at load time. Use config (below) to read/write values at runtime. They are separate — settings is the definition, config is the API.

Entry Fields

FieldTypeDescription
keystringConfig key (required)
typestring"bool", "int", "float", "keybind", "combo", or "item_slot" (defaults to "bool")
defaultanyDefault value
labelstringDisplay name in UI (defaults to key)
min, maxnumberRange for int/float sliders
optionstableString list for "combo" type
depends_onstringKey of another config entry; this entry is only shown when the dependency matches
depends_valueintValue the dependency must have (int: index, bool: 0=false/1=true)

Config API

Read and write config values at runtime:

lua
config.get_bool("enabled")          -- returns bool
config.get_int("delay")             -- returns int
config.get_float("fov")             -- returns float
config.set_bool("enabled", false)   -- write back
config.set_int("delay", 200)
config.set_float("fov", 3.0)

Config is persisted per-script as JSON in the scripts directory.