> ## Documentation Index
> Fetch the complete documentation index at: https://docs.selvut.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Settings & Commands

> Script settings and command registration in Lua.

## Settings

Settings are attached to the script module and persist with the normal module config.

```lua theme={null}
local enabled = Setting.bool("Enabled", {
  description = "Controls whether the script does work.",
  default = true
})

local delay = Setting.int("Delay Ms", {
  default = 250,
  min = 0,
  max = 5000
})

local label = Setting.text("Label", {
  default = "Ready"
})

local mode = Setting.mode("Mode", {
  default = "Normal",
  modes = { "Normal", "Aggressive" }
})
```

Supported constructors: `bool`, `number`, `int`, `integer`, `text`, `mode`, `color`, `key`, and `multiMode`.

HUD element settings use the same constructors from the HUD handle returned by `Hud.createElement`. These settings appear with that HUD element and persist with its HUD config.

```lua theme={null}
local textColor

local hud = Hud.createElement("Clock", {
  width = 80,
  height = 14,
  render = function(event)
    Render.text("FPS " .. tostring(Client.fps()), event.x, event.y, textColor.get(), true)
  end
})

textColor = hud.settings.color("Text Color", {
  default = Color.rgb(255, 255, 255)
})
```

Setting wrappers support:

| Method             | Description                     |
| ------------------ | ------------------------------- |
| `get()`            | Current value                   |
| `set(value)`       | Set value                       |
| `toggle()`         | Toggle a boolean                |
| `toggle(mode)`     | Toggle a multi-mode entry       |
| `isSelected(mode)` | Check mode/multi-mode selection |
| `modes()`          | Available modes                 |

## Commands

```lua theme={null}
Script.command("greet", {
  description = "Print a greeting.",
  usage = "greet <name>",
  parameters = {
    { name = "name", type = "string", required = false, default = "there" }
  }
}, function(args, name)
  Chat.log("Hello " .. name)
end)
```

`args.values` contains raw command arguments. `args.string(index, fallback)` reads one-based raw arguments, and `args.join(start, separator)` joins raw arguments.

Parameter types are `string`, `int`, `integer`, `number`, `double`, `float`, `bool`, and `boolean`. Add `choices = { "a", "b" }` for tab suggestions and validation.
