> For the complete documentation index, see [llms.txt](https://docs.perfectcs2.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.perfectcs2.com/documentacao/tipos/opcoes.md).

# option

Métodos das opções criadas com ui.\*.

Toda função `ui.*` devolve um objeto com estes métodos. Chame com `:`, como em `option:get()`.

| Método                                    | O que faz                                                                                                                                      |
| ----------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| `:get()`                                  | Valor atual; o tipo depende da opção (tabela abaixo)                                                                                           |
| `:set(value)`                             | Muda o valor, como se a pessoa tivesse mexido. Números são limitados ao mínimo e máximo.                                                       |
| `:get_color()` / `:set_color(color)`      | Cor de um `ui.toggle` com cor ou de um `ui.color`                                                                                              |
| `:visible()` / `:visible(bool)`           | Lê ou muda se a linha aparece                                                                                                                  |
| `:enabled()` / `:enabled(bool, [reason])` | Lê ou muda se a linha pode ser usada. Desligada, ela fica apagada e mostra `reason` ao passar o mouse.                                         |
| `:tooltip(text)`                          | Dica ao passar o mouse na linha; `""` remove                                                                                                   |
| `:label()` / `:label(text)`               | Lê ou troca o título da linha                                                                                                                  |
| `:description()` / `:description(text)`   | Lê ou troca a descrição                                                                                                                        |
| `:items()` / `:items(list)`               | Lê ou troca os itens de um `combo` ou `multiselect`                                                                                            |
| `:callback(fn)`                           | `fn(option)` roda sempre que a pessoa muda o valor; `nil` remove                                                                               |
| `:is_down()` / `:is_pressed()`            | Só em `keybind`: a tecla escolhida está apertada? Foi apertada agora?                                                                          |
| `:type()`                                 | `"toggle"`, `"slider"`, `"slider_int"`, `"combo"`, `"multiselect"`, `"color"`, `"keybind"`, `"button"`, `"textbox"`, `"text"` ou `"separator"` |
| `:id()`                                   | Número único da opção dentro do script                                                                                                         |

## O que `:get()` devolve

| Opção         | `:get()`                                                     |
| ------------- | ------------------------------------------------------------ |
| `toggle`      | `boolean` e, se tiver cor, a `color`                         |
| `slider`      | `number`                                                     |
| `slider_int`  | `integer`                                                    |
| `combo`       | nome do item e posição (1, 2, …)                             |
| `multiselect` | tabela com os nomes marcados; `:get(name)` devolve `boolean` |
| `color`       | `color`                                                      |
| `keybind`     | nome da tecla ou `nil`                                       |
| `button`      | quantas vezes foi clicado                                    |
| `textbox`     | `string`                                                     |
| `text`        | o título                                                     |

## Esconder e bloquear conforme outra opção

```lua
local style      = ui.combo("Style", "", { "Lines", "Dot" })
local gap        = ui.slider_int("Gap", "Space between the lines", 0, 10, 3)
local advanced   = ui.toggle("Advanced", "Shows more options")
local smoothness = ui.slider("Smoothness", "", 1, 10, 5)

local function refresh()
    gap:enabled(style:get() == "Lines", "Only for the Lines style")
    smoothness:visible(advanced:get())
end
style:callback(refresh)
advanced:callback(refresh)
refresh() -- initial state
```

{% hint style="info" %}
`:callback` só roda quando **a pessoa** muda a opção no menu. Mudanças feitas pelo próprio script com `:set` não chamam o callback.
{% 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.perfectcs2.com/documentacao/tipos/opcoes.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.
