> For the complete documentation index, see [llms.txt](https://docs.autowall.fun/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.autowall.fun/documentation/vars/ui.md).

# UI

## UI

Two ways to use `ui.*`, both backed by the same underlying control storage:

1. **Local to your script** — don't call `ui.create_tab`; controls show up in the Lua tab's own **Controls** panel while your script is open there. This is the original behavior.
2. **A real menu tab** — call `ui.create_tab(tab, subtab)` once; every `ui.switch`/`slider`/`combo`/`input`/`color_picker`/`button` your script (or *any* running script) registers under that same `tab` name renders as a real tab in the app's menu, grouped by `subtab`, using the exact same widgets (`elem::toggle`, `elem::slider_float`, ...) the built-in tabs use.

```lua
ui.create_tab(tab, subtab)     -- creates the tab once; safe to call every run
ui.create_group(tab, subtab, group)  -- accepted for API compatibility; no-op
                                       -- (grouping is implicit from each control's `group` arg)
ui.is_open()                    -- bool, whether the menu is currently presented
```

### Creating elements

```lua
local sw = ui.switch(tab, sub, group, label, default_bool)
local sl = ui.slider(tab, sub, group, label, min, max, default_float)
local cb = ui.combo(tab, sub, group, label, { "a", "b", "c" }, default_index)
local cp = ui.color_picker(tab, sub, group, label, { 1, 1, 1, 1 })
local ti = ui.input(tab, sub, group, label, default_string)
local bt = ui.button(tab, sub, group, label, function() ... end)
```

* `tab`/`sub`/`group`/`label` (the spec's `category`/`script`/`section`/`name`) together form the control's identity (`tab/group/label`, `sub` is a pure display grouping hint) — calling the same signature again in the same script returns the **existing** control, not a fresh default.
* `combo`'s index and `:get()` value are **1-based**.
* `color_picker`'s value is `{r, g, b, a}` in **0..1**, not a `color()` object.
* `button`'s 5th argument is a function called (protected — an error in it won't crash anything) whenever it's pressed; it has no `:get()` value.

### Item methods

```lua
sw:get()                      -- current value (see per-type shapes in Color/Vector/Basic Types)
sw:set(value)                 -- set programmatically; persists immediately
sw:visible(bool)              -- static show/hide; no function form yet
sw:depend(other, expected?)   -- only drawn (and only counted `:visible`) while
                               -- other:get() == expected (default true) -- other
                               -- must be a switch from the *same* script
sw:on_change(function() ... end)  -- called (protected) whenever the widget changes
```

### Global helpers

```lua
ui.find(tab, sub, group, label)   -- item | nil, searches the *currently running* script only
ui.get_value(item)                -- same as item:get()
ui.set_value(item, value)         -- same as item:set(value)
ui.set_visible(item, bool)        -- same as item:visible(bool)
ui.on_change(item, fn)            -- same as item:on_change(fn)
ui.depend(item, other, expected)  -- same as item:depend(other, expected)
```

### Example: dependent controls in a real tab

```lua
ui.create_tab("Lua", "demo")

local master = ui.switch("Lua", "demo", "main", "enabled", true)
local amount = ui.slider("Lua", "demo", "main", "amount", 0, 100, 50)
amount:depend(master, true)

amount:on_change(function()
    print("amount changed", amount:get())
end)
```

### Not implemented yet

{% hint style="danger" %}
See [Roadmap](/documentation/roadmap-not-implemented-yet.md#ui) — `ui.keybind`, `ui.multiselect`, `ui.list`, `ui.selectable`, cross-script `ui.find`/`:depend`, function-form `:visible(fn)`, and the built-in engine config paths (`ragebot.enabled`, `esp.box`, etc via `ui.get`/`ui.set`/`ui.find`).
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.autowall.fun/documentation/vars/ui.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
