# Terminal

{% hint style="info" %}
Included commands are for demonstration purposes only.
{% endhint %}

> Designed to mimic the look and feel of a traditional terminal, this app provides an intuitive and powerful tool for executing various commands.

<figure><img src="https://1688068901-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9bCwnajAqpi3Viykb5Wi%2Fuploads%2FsS6lsbKQwvgzihfRGNXE%2F%7B3EE7F5D0-9A40-4673-AC7D-4EB088FA0680%7D.png?alt=media&#x26;token=b579351e-ffde-4633-bd05-9313f173270d" alt=""><figcaption></figcaption></figure>

#### Register Commands

* Navigate to `av_laptop/server/editable/_terminal.lua`
* Add your custom commands to the `allCommands` table using the following structure:

#### Base Properties

* **index key**:`string` The command trigger. This must be unique.
* **show**:`boolean` Displays the command when command help is used.
* **args?**:`string` Defines the required parameters for the command. All parameters are combined into a single string, with each one enclosed in angle brackets (`< >`)&#x20;

  ```lua
  args = "<Input 1> <Input 2> <Input 3>"
  ```
* **allowed**: `function(playerId, laptopSerial)` Returns `true` or `false`. Determines if the player is permitted to see and use the command. If `false`, the command will be hidden from the `/help` list.
* **canProcess**: `function(playerId, laptopSerial, args)` Verifies that the user meets the requirements to execute the command (e.g., special permissions, specific items, or required arguments).
* **onSuccess:** `function(playerId, laptopSerial, args)` This function runs only if `canProcess` returns `true`. Use this to execute any custom server-side logic.
* **actions:**`table[]` A sequence of actions executed by the terminal in descending order. Each action supports the following properties:

#### Action Properties

* **type:**`string` The action to perform.&#x20;
  * Available options: `"text"`, `"progressbar"`, `"minigame"` `"external"` `"userInput"` `"table"`&#x20;
* **input?:**`string` The content to be processed (e.g., the text to display or the name of the minigame to trigger). List of available minigames can be found in the Minigames section.
* **delay:**`number` The duration (in milliseconds) to wait before executing the next action in the sequence.
* **style:**`string` *Optional.* Used with the `"text"` type to apply an `"error"` or `"output"` visual style.
* **callback?**:`string` Callback to trigger after action gets completed, this callback should be already registered client side, you can find an example here: [exports](https://docs.av-scripts.com/laptop-pack-v3/laptop-v3/terminal/exports "mention")
* **output:**`table[]` The final message rendered once all actions and minigames have been successfully completed.
  * **message (string):** The text content to display.
  * **color (string):** The HEX or CSS color for the text.

```lua
['jailbreak'] = { -- command used, should be unique and also a string
        show = true,
        args = "<Input 1> <Input 2> <Input 3>",
        allowed = function(playerId, laptopSerial)
            return true
        end,
        canProcess = function(playerId, laptopSerial, args)
            return true
        end,
        onSuccess = function(playerId, laptopSerial, args)
            print("onSuccess()")
        end,
        actions = {
            {type = "text", input = "Accessing local kernel bootloader...", delay = 600},
            {type = "progressbar", input = "Corrupting security signed-boot", delay = 4000},
            {type = "text", input = "Warning: Integrity check bypassed. System unstable.", style = "error", delay = 1000},
            {type = "progressbar", input = "Mounting read-write partition", delay = 3500},
            {type = "text", input = "Injecting unsigned binary signature...", delay = 500},
            {type = "minigame", input = "grid", label = "KERNEL_VULN_MAPPER"}
        },
        output = {
            message = ">>> SYSTEM JAILBROKEN: RESTRICTIONS REMOVED. THIRD-PARTY APPS ENABLED.",
            color = "teal"
        }
    },
```

#### Table

The `table` action renders a structured data grid directly within the terminal output. It is highly useful for displaying organized lists, such as nearby networks, vehicle data, or directory contents.

Properties:

* `type` (string): Must be exactly `"table"`.
* `columns` (array): An array of strings defining the header titles.
* `rows` (array): A multi-dimensional array containing the row data. The data order must match the defined columns.
* `delay` (number): The pause duration in milliseconds after rendering the table before executing the next action.

*You can find a demo script using Tables in* [#keyfob-example](https://docs.av-scripts.com/laptop-pack-v3/laptop-v3/exports#keyfob-example "mention")

```lua
local data = {}

table.insert(data, {
    "ABC123",
    "Asea",
    "avscripts",
    string.format("%.1fm", 2.0)
})

local actionConfig = {
    type = "table",
    columns = {"PLATE", "MODEL", "SSID", "DISTANCE"},
    rows = data,
    delay = 0
}
```
