# Menu API

The menu API lets scripts add UI elements to the cheat menu. All elements are identified by a string `id` that you use to read and write values later.

> All examples use `snake_case`. Every function is also accessible in `camelCase` and `PascalCase` — the engine accepts all three. Pick one and stay consistent in your scripts.

***

### Setup — tabs and groups

Every element must live inside a tab and a group. Create them before adding elements:

```lua
menu.add_tab("Visuals", "V")           -- name, icon letter
menu.add_group("Visuals", "Players")   -- tab name, group name
```

All `add_*` functions take `tab` and `group` as the first two arguments.

***

### menu.add\_checkbox

```lua
menu.add_checkbox(tab, group, id, label, default, options)
```

| Parameter | Type    | Required | Description                   |
| --------- | ------- | -------- | ----------------------------- |
| `tab`     | string  | yes      | Tab name                      |
| `group`   | string  | yes      | Group name                    |
| `id`      | string  | yes      | Unique element ID             |
| `label`   | string  | yes      | Display label                 |
| `default` | boolean | yes      | Default value                 |
| `options` | table   | no       | Optional settings (see below) |

**Options table:**

| Key           | Type              | Description                              |
| ------------- | ----------------- | ---------------------------------------- |
| `key`         | number            | Attach a hotkey (VK code)                |
| `colorpicker` | table `{r,g,b,a}` | Attach an inline colorpicker             |
| `color`       | table `{r,g,b,a}` | Attach a color swatch                    |
| `parent`      | string            | Element ID to use as a visibility parent |
| `show_mode`   | boolean           | Show hotkey mode selector                |

```lua
-- basic
menu.add_checkbox("Visuals", "Players", "esp_on", "Enable ESP", false)

-- with hotkey and colorpicker
menu.add_checkbox("Visuals", "Players", "esp_on", "Enable ESP", false, {
    key = 0x2E,
    colorpicker = {1, 1, 1, 1},
})
```

***

### menu.add\_slider\_int

```lua
menu.add_slider_int(tab, group, id, label, min, max, default, options)
```

```lua
menu.add_slider_int("Visuals", "Players", "fov_size", "FOV Size", 10, 300, 90)

-- with format string
menu.add_slider_int("Visuals", "Players", "fov_size", "FOV Size", 10, 300, 90, "%dpx")

-- with parent
menu.add_slider_int("Visuals", "Players", "fov_size", "FOV Size", 10, 300, 90,
    { parent = "aimbot_on" })
```

***

### menu.add\_slider\_float

```lua
menu.add_slider_float(tab, group, id, label, min, max, default, options)
```

```lua
menu.add_slider_float("Aimbot", "Settings", "smooth", "Smooth", 0.0, 1.0, 0.15)

-- with format string and parent
menu.add_slider_float("Aimbot", "Settings", "smooth", "Smooth", 0.0, 1.0, 0.15, "%.2f",
    { parent = "aimbot_on" })
```

***

### menu.add\_combo

```lua
menu.add_combo(tab, group, id, label, items, default_index, options)
```

Returns the selected item as a zero-based index.

```lua
menu.add_combo("Visuals", "Players", "box_style", "Box Style",
    {"Normal", "Corner", "Filled"}, 0)
```

***

### menu.add\_multicombo

```lua
menu.add_multicombo(tab, group, id, label, items, defaults)
```

Returns a table of booleans, one per item.

```lua
menu.add_multicombo("Visuals", "Players", "bone_list", "Bones",
    {"Head", "Torso", "Arms", "Legs"},
    {true, true, false, false})
```

***

### menu.add\_button

```lua
menu.add_button(tab, group, id, label, callback)
```

```lua
menu.add_button("Config", "Actions", "reload_btn", "Reload Config", function()
    print("reloading...")
end)
```

***

### menu.add\_colorpicker

```lua
menu.add_colorpicker(tab, group, id, label, default_rgba, options)
```

```lua
menu.add_colorpicker("Visuals", "Players", "esp_color", "ESP Color", {1, 1, 1, 1})

-- with parent
menu.add_colorpicker("Visuals", "Players", "esp_color", "ESP Color", {1, 1, 1, 1},
    { parent = "esp_on" })
```

***

### menu.add\_hotkey

```lua
menu.add_hotkey(tab, group, id, label, default_key, options)
```

```lua
menu.add_hotkey("Aimbot", "Settings", "aim_key", "Aimbot Key", 0x02)
```

***

### menu.add\_input

```lua
menu.add_input(tab, group, id, label, default_text)
```

```lua
menu.add_input("Config", "General", "prefix", "Chat Prefix", "[VEC]")
```

***

### menu.add\_label

```lua
menu.add_label(tab, group, text)
```

Renders a dimmed text label. No ID required.

```lua
menu.add_label("Visuals", "Players", "Colors are in RGBA 0-1 range")
```

***

### menu.add\_separator

```lua
menu.add_separator(tab, group)
```

Inserts a vertical spacer between elements.

***

### Reading values

```lua
local enabled = menu.get("esp_on")        -- boolean
local fov     = menu.get("fov_size")      -- number (int)
local smooth  = menu.get("smooth")        -- number (float)
local style   = menu.get("box_style")     -- number (zero-based index)
local bones   = menu.get("bone_list")     -- table of booleans
local text    = menu.get("prefix")        -- string
local color   = menu.get_color("esp_color")  -- {r, g, b, a}
local key     = menu.get_key("aim_key")   -- number (VK code)
```

***

### Writing values

```lua
menu.set("esp_on", true)
menu.set("fov_size", 120)
menu.set("smooth", 0.2)
menu.set("box_style", 1)
menu.set_color("esp_color", {0, 1, 0.8, 1})
menu.set_key("aim_key", 0x02)
```

***

### Callbacks

Called whenever the user changes the value of an element.

```lua
menu.set_callback("fov_size", function(new_value)
    print("fov changed to: " .. new_value)
end)

menu.set_callback("esp_on", function(new_value)
    print("esp is now: " .. tostring(new_value))
end)
```

***

### Visibility

```lua
menu.set_visible("fov_size", false)
menu.set_visible("fov_size", true)
```

***

### Parent (conditional visibility)

Attach elements to a checkbox — they only render when the checkbox is enabled:

```lua
menu.add_checkbox("Aimbot", "Settings", "aimbot_on", "Enable Aimbot", false)

menu.add_slider_float("Aimbot", "Settings", "smooth", "Smooth",
    0.0, 1.0, 0.15, { parent = "aimbot_on" })

menu.add_slider_int("Aimbot", "Settings", "fov", "FOV",
    10, 300, 90, { parent = "aimbot_on" })

menu.add_hotkey("Aimbot", "Settings", "aim_key", "Key",
    0x02, { parent = "aimbot_on" })
```

***

### Full setup example

```lua
-- tabs and groups
menu.add_tab("Visuals", "V")
menu.add_group("Visuals", "ESP")

menu.add_tab("Aimbot", "A")
menu.add_group("Aimbot", "Settings")

-- visuals
menu.add_checkbox("Visuals", "ESP", "esp_on",    "Enable ESP",  false)
menu.add_checkbox("Visuals", "ESP", "esp_names", "Names",       true,  { parent = "esp_on" })
menu.add_checkbox("Visuals", "ESP", "esp_boxes", "Boxes",       true,  { parent = "esp_on" })
menu.add_combo("Visuals",    "ESP", "box_style", "Box Style",   {"Normal", "Corner"}, 0)
menu.add_colorpicker("Visuals", "ESP", "esp_col", "Color",      {1, 1, 1, 1})
menu.add_slider_float("Visuals", "ESP", "esp_dist", "Max Dist", 0, 500, 200, { parent = "esp_on" })

-- aimbot
menu.add_checkbox("Aimbot", "Settings", "aimbot_on", "Enable Aimbot", false)
menu.add_slider_float("Aimbot", "Settings", "smooth",  "Smooth",  0.0, 1.0, 0.15, { parent = "aimbot_on" })
menu.add_slider_int("Aimbot",   "Settings", "fov",     "FOV",     10, 300, 90,    { parent = "aimbot_on" })
menu.add_hotkey("Aimbot",       "Settings", "aim_key", "Key",     0x02)

-- on_frame usage
function on_frame()
    if not menu.get("esp_on") then return end

    local color = menu.get_color("esp_col")
    local style = menu.get("box_style")
    local players = entity.get_players()

    for _, p in ipairs(players) do
        if p.is_local or not p.is_alive then goto continue end

        local b = p:get_bounds()
        if not b.valid then goto continue end

        draw.box(b.x, b.y, b.w, b.h, color, 0, style)

        if menu.get("esp_names") then
            local tw, th = draw.get_text_size(p.name, 14)
            draw.text(b.x + b.w / 2 - tw / 2, b.y - th - 2, p.name, {1, 1, 1, 1})
        end

        ::continue::
    end
end
```

***

### API Reference

| Function                     | Returns | Description                   |
| ---------------------------- | ------- | ----------------------------- |
| `menu.add_tab(name, icon)`   | —       | Register a tab                |
| `menu.add_group(tab, name)`  | —       | Register a group inside a tab |
| `menu.add_checkbox(...)`     | —       | Add a checkbox                |
| `menu.add_slider_int(...)`   | —       | Add an integer slider         |
| `menu.add_slider_float(...)` | —       | Add a float slider            |
| `menu.add_combo(...)`        | —       | Add a dropdown                |
| `menu.add_multicombo(...)`   | —       | Add a multi-select dropdown   |
| `menu.add_button(...)`       | —       | Add a button                  |
| `menu.add_colorpicker(...)`  | —       | Add a color picker            |
| `menu.add_hotkey(...)`       | —       | Add a key bind widget         |
| `menu.add_input(...)`        | —       | Add a text input              |
| `menu.add_label(...)`        | —       | Add a text label              |
| `menu.add_separator(...)`    | —       | Add a spacer                  |
| `menu.get(id)`               | any     | Read element value            |
| `menu.get_color(id)`         | table   | Read color value              |
| `menu.get_key(id)`           | number  | Read key value                |
| `menu.set(id, value)`        | —       | Write element value           |
| `menu.set_color(id, rgba)`   | —       | Write color value             |
| `menu.set_key(id, vk)`       | —       | Write key value               |
| `menu.set_callback(id, fn)`  | —       | Set on-change callback        |
| `menu.set_visible(id, bool)` | —       | Show or hide element          |


---

# Agent Instructions: 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:

```
GET https://project-vector-1.gitbook.io/vector-lua-engine/api/menu-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
