> 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/ru/api-reference/menyu.md).

# Меню

Создание элементов меню и управление их значениями.

Библиотека `menu` предназначена для создания настроек в интерфейсе. Каждая функция создания элемента возвращает `menu_item`, через который можно читать и менять значение.

## Элементы меню

### menu.checkbox

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

Создаёт переключатель. По умолчанию выключен.

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

Слайдер целого числа в заданном диапазоне. Если `default` не указан, используется `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`

Слайдер с дробным значением. Формат по умолчанию — `"%.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`

Выпадающий список с одним выбранным вариантом. `:get()` возвращает **номер варианта от 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`

Список, в котором можно выбрать несколько вариантов. `:get()` возвращает таблицу выбранных индексов, начиная с 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`

Добавляет выбор цвета. Цвет задаётся каналами `r`, `g`, `b`, `a` от 0 до 255; `a` необязателен.

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

### menu.input

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

Текстовое поле. Возвращаемое значение — строка.

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

### menu.button

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

Кнопка, которая запускает `callback` при нажатии.

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

menu.button("Reset", function()
    enabled:set(false)
end)
```

### menu.label

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

Добавляет текстовую подпись. Её содержимое можно изменить через `:set()`.

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

### menu.keybind

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

Добавляет привязку клавиши. Текущее состояние возвращает `:get()`.

Режимы: `"always"`, `"hold"` (по умолчанию), `"toggle"`, `"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

### :get()

`item:get(): any`

Возвращает текущее значение. Для `combo` — индекс, для `multicombo` — список индексов, для `color` — таблицу `{r, g, b, a}`. Для кнопки — `nil`.

### :set()

`item:set(value: any)`

Меняет значение элемента. Тип должен соответствовать элементу; для `combo` и `multicombo` индексы начинаются с 1. Не поддерживается для кнопки и keybind.

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

### :on\_change()

`item:on_change(callback: function)`

Назначает функцию, которая вызывается при изменении элемента пользователем в меню.

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

Показывает или скрывает элемент.

### :active()

`item:active(): boolean`

Возвращает внутреннее состояние переключателя; для проверки обычного значения удобнее использовать `:get()`.

> В одном скрипте можно создать до **64 элементов меню**. Один список `combo` или `multicombo` содержит от 1 до 32 вариантов.


---

# 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/ru/api-reference/menyu.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.
