> For the complete documentation index, see [llms.txt](https://docs.gamesense.biz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.gamesense.biz/api-reference/menu.md).

# Menu

Create controls and manage menu\_item values.

The `menu` library provides controls for a script's settings. Each control constructor returns a `menu_item` object that can be read and, where supported, modified.

## Controls

### menu.checkbox

`menu.checkbox(label: string[, default: boolean]): menu_item`

Creates a checkbox. Defaults to `false`.

```lua
local enabled = menu.checkbox("Enabled", true)
local is_enabled = enabled:get()
```

### menu.slider\_int

`menu.slider_int(label: string, min: number, max: number[, default: number]): menu_item`

Creates an integer slider. The default value is `min` when omitted.

```lua
local damage = menu.slider_int("Damage", 1, 100, 50)
local value = damage:get()
```

### menu.slider\_float

`menu.slider_float(label: string, min: number, max: number[, default: number, format: string]): menu_item`

Creates a floating-point slider. Default format: `"%.2f"`.

```lua
local scale = menu.slider_float("Scale", 0.5, 2.0, 1.0, "%.1f")
```

### menu.combo

`menu.combo(label: string, options: table[, default: number]): menu_item`

Creates a single-selection dropdown. `:get()` returns the **1-based** index of the selected option.

```lua
local mode = menu.combo("Mode", {"Off", "Normal", "Fast"}, 2)
local selected = mode:get() -- 2
```

### menu.multicombo

`menu.multicombo(label: string, options: table[, defaults: table]): menu_item`

Creates a multi-selection dropdown. `:get()` returns a table of selected **1-based** indices.

```lua
local flags = menu.multicombo("Flags", {"Health", "Armor", "Name"}, {1, 3})
local selected = flags:get()
```

### menu.color

`menu.color(label: string[, color: table]): menu_item`

Creates a color picker. The `r`, `g`, `b`, and optional `a` channels range from 0 to 255.

```lua
local accent = menu.color("Accent", {r = 120, g = 180, b = 255, a = 255})
local color = accent:get()
```

### menu.input

`menu.input(label: string[, default: string]): menu_item`

Creates a text input.

```lua
local nickname = menu.input("Nickname", "Player")
local text = nickname:get()
```

### menu.button

`menu.button(label: string, callback: function): menu_item`

Creates a button that invokes its callback when pressed.

```lua
local enabled = menu.checkbox("Enabled", true)
menu.button("Reset", function()
    enabled:set(false)
end)
```

### menu.label

`menu.label(text: string): menu_item`

Creates a text label. Its contents can be changed using `:set()`.

```lua
local status = menu.label("Status: idle")
status:set("Status: ready")
```

### menu.keybind

`menu.keybind(label: string[, mode: string]): menu_item`

Creates a keybind. Its active state is available through `:get()`.

Modes: `"always"`, `"hold"` (default), `"toggle"`, and `"hold_inverted"`.

```lua
local hotkey = menu.keybind("Hotkey", "hold")
local indicator = menu.label("Keybind: inactive")

register_callback("on_update", function()
    indicator:set(hotkey:get() and "Keybind: active" or "Keybind: inactive")
end)
```

## menu\_item methods

### :get()

`item:get(): any`

Returns the current value. For `combo`, returns an index; for `multicombo`, a table of indices; for `color`, a color table. Buttons return `nil`.

### :set()

`item:set(value: any)`

Changes the control value. The supplied type must match the control. Not supported for buttons or keybinds.

```lua
local speed = menu.slider_int("Speed", 0, 100, 25)
speed:set(70)
```

### :on\_change()

`item:on_change(callback: function)`

Registers a handler for changes made through the menu.

```lua
local enabled = menu.checkbox("Enabled", false)
local amount = menu.slider_int("Amount", 0, 100, 50)

enabled:on_change(function()
    amount:set_visible(enabled:get())
end)
```

### :set\_visible()

`item:set_visible(visible: boolean)`

Shows or hides a control.

### :active()

`item:active(): boolean`

Returns the control's internal active state. For most value checks, `:get()` is preferable.

{% hint style="info" %}
A script can create up to **64 menu controls**. A combo or multicombo supports **1–32 options**.
{% 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 by asking a question.

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

```
GET https://docs.gamesense.biz/api-reference/menu.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.
