> For the complete documentation index, see [llms.txt](https://scripter-sm.gitbook.io/elite-zone/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://scripter-sm.gitbook.io/elite-zone/api-reference/api.ui.md).

# api.ui

Find, read, change, remove and build anything in the Elite Zone menu.

Everything in the Elite Zone menu, and the containers it is built out of.

## Reading and changing settings

Every menu setting has a name called its idx, like `"ragebot_strafe"`.

| Call                     | Returns                                                                      |
| ------------------------ | ---------------------------------------------------------------------------- |
| `api.ui.tree()`          | the whole menu as `tree[tab][section] = list of entries`                     |
| `api.ui.list(prefix?)`   | flat list of entries, optionally only names starting with `prefix`           |
| `api.ui.where(idx)`      | the tab and section the setting is in                                        |
| `api.ui.tabs()`          | list of tab names                                                            |
| `api.ui.get(idx)`        | the current value                                                            |
| `api.ui.set(idx, value)` | changes the value like a click in the menu                                   |
| `api.ui.remove(idx)`     | removes the setting from the menu                                            |
| `api.ui.element(idx)`    | the raw menu element, with `.Value`, `.Values`, `:SetValue` and `:OnChanged` |

Each entry has `idx`, `type` (`"Toggle"`, `"Slider"`, `"Dropdown"`, `"Input"`, `"ColorPicker"` or `"KeyPicker"`), `value`, `values` (dropdown choices), `tab` and `section`.

## Getting at groups and tabs

Use these when you want your settings to sit inside a part of the menu that already exists, instead of building a tab of your own.

| Call                        | Returns                                           |
| --------------------------- | ------------------------------------------------- |
| `api.ui.box(tab, name)`     | the groupbox with that name on that tab, or `nil` |
| `api.ui.tabbox(tab, name?)` | the tabbox on that tab, or `nil`                  |

`tab` is a tab name or a tab object, so `"main"` and `api.ui.window.Tabs.main` both work.

Elite Zone's own tabboxes are unnamed, which is why `name` is optional and defaults to `""`. A named tabbox, from `lua:tabbox` passing a name or from your own code, is found by that name.

Both return a live groupbox, so you can add settings to it exactly like one of your own:

```lua
local mine = api.ui.tabbox("main"):AddTab("my lua")
mine:AddToggle("my_lua_enabled", { Text = "enabled", Default = true })

local options = api.ui.box("main", "options")
options:AddSlider("my_lua_depth", { Text = "depth", Default = 3, Min = 1, Max = 10, Rounding = 0 })
```

## Cleaning up after yourself

Anything you build with `lua:tab`, `lua:box` or `lua:tabbox` is removed for you on unload. Anything you add to a container that **Elite Zone or another Lua owns** is not, because that container has to stay put for whoever else is using it.

Keep what you added and remove it in `lua.on_unload`. Groupboxes and tabs inside a tabbox both have `:Remove()`:

```lua
local mine = api.ui.tabbox("main"):AddTab("my lua")
mine:AddToggle("my_lua_enabled", { Text = "enabled", Default = true })

lua.on_unload = function()
    mine:Remove()
end
```

Removing a tab from a tabbox shows whichever tab is left, so the row of tab buttons resizes itself. If you were the last tab, the tabbox disappears until something is added to it again.

{% hint style="info" %}
Removing a group removes the settings inside it, but the names stay registered with the menu. Read your settings with `api.ui.element(idx)` rather than caching them at load time if you reload often.
{% endhint %}

## The window

`api.ui.window` is the window itself. `api.ui.window.Tabs[name]` is an existing tab.


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://scripter-sm.gitbook.io/elite-zone/api-reference/api.ui.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
