> For the complete documentation index, see [llms.txt](https://lua2.fatality.win/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lua2.fatality.win/api/instances/gui/control/slider.md).

# Slider

This type represents a slider control.

{% hint style="info" %}
This type inherits [`Control`](/api/instances/gui/control.md) type. All of its base methods and fields are also available in this type.
{% endhint %}

## \_\_call﻿ <a href="#call" id="call"></a>

[<kbd><mark style="background-color:purple;">**Constructor**<mark style="background-color:purple;"></kbd>](#user-content-fn-1)[^1]

Constructs the slider.

**Arguments**

| Name   | Type                                                           | Description                     |
| ------ | -------------------------------------------------------------- | ------------------------------- |
| `id`   | [`ControlID`](/api/instances/gui/types/controlid.md)`\|string` | Control ID.                     |
| `low`  | `float`                                                        | Minimum value.                  |
| `high` | `float`                                                        | Maximum value.                  |
| `fmt`  | `table[...]`                                                   | Format. Defaults to `{'%.0f'}`. |
| `step` | `float`                                                        | Step value. Defaults to `1.0`.  |

Format Table

{% hint style="info" %}
Format table can either be a single string with the desired format, or multiple elements with different minimum actuators. You have to pass multiple values in the descendant order, starting from the highest value to the lowest value. `min` and `add` values are both optional, but it makes no sense to leave either of them out.
{% endhint %}

{% hint style="success" %}
Formatting uses standard `printf` syntax. [Documentation](https://cplusplus.com/reference/cstdio/printf/)
{% endhint %}

{% hint style="danger" %}
Passing invalid format will lead to an undefined behavior.
{% endhint %}

1\. Single Formatting.

| Type     | Description    |
| -------- | -------------- |
| `string` | Format string. |

2\. Multi Formatting.

| Name  | Type     | Description    |
| ----- | -------- | -------------- |
| `min` | `float?` | Minimal value. |
| `add` | `float?` | Add step.      |
| `fmt` | `string` | Format string. |

**Returns**

| Type     | Description    |
| -------- | -------------- |
| `Slider` | Slider object. |

**Example**

```lua
local slider = gui.Slider(id, 0, 100, {'%.0f%%'});
```

***

## GetValue <a href="#get-value" id="get-value"></a>

[<kbd><mark style="background-color:purple;">**Method**<mark style="background-color:purple;"></kbd>](#user-content-fn-2)[^2]

Returns slider' value.

**Arguments**

None.

**Returns**

| Type                                                                                                          | Description |
| ------------------------------------------------------------------------------------------------------------- | ----------- |
| [`ValueParam`](/api/instances/gui/control/valueparam.md)[`<float>`](/api/instances/gui/control/valueparam.md) | Value data. |

Example

```lua
local val = slider:GetValue():Get();
```

***

## Get <a href="#get-value" id="get-value"></a>

[<kbd><mark style="background-color:purple;">**Method**<mark style="background-color:purple;"></kbd>](#user-content-fn-2)[^2]

Returns value directly. Alias for `GetValue():Get()` .

**Arguments**

None.

**Returns**

| Type     | Description |
| -------- | ----------- |
| `number` | Value.      |

**Example**

```lua
local val = slider:Get();
```

[^1]: This is a constructor definition for this type.

[^2]: This field is a method and must be invoked using a colon (:)


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://lua2.fatality.win/api/instances/gui/control/slider.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.
