# Progressbar

## Progressbar Functions

### `startProgressbar(data, callback)`

Starts a progress bar and returns a completion status.

**Parameters:**

* **`data.icon`** (string)\
  The FontAwesome icon to display.
* **`data.label`** (string)\
  The text to display on the progress bar.
* **`data.time`** (number)\
  The duration of the progress bar in seconds.
* **`data.animation`** (table)\
  Animation configuration:
  * **`data.animation.dict`** (string): The animation dictionary.
  * **`data.animation.name`** (string): The animation name.
* **`data.inputBlock`** (table)\
  Input blocking configuration:
  * **`data.inputBlock.keys`** (table): A list of keys to block.
* **`data.cancelable`** (boolean)\
  Specifies whether the progress bar can be canceled by pressing `X` (default is `true`).
* **`callback`** (function)\
  A callback function that returns:
  * `true` if the progress bar completed successfully,
  * `false` if it was canceled.

***

### `cancelProgressbar()`

Cancels the active progress bar and stops any associated animation.

***

### Exports

This module exports two functions for use in other scripts:

exports\["script\_name"]:startProgressbar(data, function(isDone) ... end)

`exports["script_name"]:cancelProgressbar()`

***

### Usage Example

```lua
RegisterCommand("testprogress", function(source, args, rawCommand)
    local data = {
        icon = "fa-solid fa-hammer",
        label = "Sample progress...",
        time = 5,
        animation = {
            dict = "amb@world_human_hammering@male@base",
            name = "base"
        },
        inputBlock = {
            keys = {"W", "A", "S", "D"}
        },
        cancelable = true
    }
    
    exports["KOJA_HUD"]:startProgressbar(data, function(isDone)
        if isDone then
            print("Progressbar completed successfully!")
        else
            print("Progressbar was canceled!")
        end
    end)
end, false)
```


---

# Agent Instructions: 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://docs.kojascripts.eu/new/hud/guides/progressbar.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.
