> 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/pt-br/api-reference/menu.md).

# Menu

Criação de controles e gerenciamento de valores do menu.

A biblioteca `menu` permite adicionar controles às configurações de um script. Cada função de criação retorna um objeto `menu_item`, usado para consultar e, quando permitido, alterar o valor.

## Controles

### menu.checkbox

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

Cria uma caixa de seleção. O valor padrão é `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`

Cria um controle deslizante de números inteiros. Quando omitido, o valor padrão é `min`.

```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`

Cria um controle deslizante de números decimais. Formato padrão: `"%.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`

Cria uma lista de seleção única. `:get()` retorna o índice da opção selecionada, começando em **1**.

```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`

Cria uma lista de seleção múltipla. `:get()` retorna uma tabela com os índices selecionados, começando em **1**.

```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`

Cria um seletor de cores. Os canais `r`, `g`, `b` e o opcional `a` variam de 0 a 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`

Cria um campo de texto.

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

### menu.button

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

Cria um botão que executa o callback quando é pressionado.

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

### menu.label

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

Cria um rótulo de texto. O conteúdo pode ser atualizado com `:set()`.

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

### menu.keybind

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

Cria um atalho de tecla. O estado atual pode ser consultado com `:get()`.

Modos: `"always"`, `"hold"` (padrão), `"toggle"` e `"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)
```

## Métodos de menu\_item

### :get()

`item:get(): any`

Retorna o valor atual. Para `combo`, retorna um índice; para `multicombo`, uma tabela de índices; para `color`, uma tabela de canais. Botões retornam `nil`.

### :set()

`item:set(value: any)`

Altera o valor do controle. O tipo deve corresponder ao controle. Não é permitido para botões e atalhos de tecla.

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

### :on\_change()

`item:on_change(callback: function)`

Registra uma função para alterações realizadas na interface.

```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)`

Exibe ou oculta o controle.

### :active()

`item:active(): boolean`

Retorna o estado ativo interno do controle. Para consultar valores, geralmente é preferível usar `:get()`.

{% hint style="info" %}
Um script pode criar até **64 controles de menu**. Listas `combo` e `multicombo` aceitam de **1 a 32 opções**.
{% 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/pt-br/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.
