> For the complete documentation index, see [llms.txt](https://organized-chaos.gitbook.io/organized-chaos-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://organized-chaos.gitbook.io/organized-chaos-docs/the-lost-treasure/commands-and-exports.md).

# Commands and exports

Every command, permission, convar and export of The Lost Treasure.

## Commands

| Command                                         | Who                                       | What it does                                                             |
| ----------------------------------------------- | ----------------------------------------- | ------------------------------------------------------------------------ |
| `/slot`                                         | Everyone, while `Config.UseCommand` is on | Opens the game without a machine                                         |
| `/lost_treasure_admin`                          | Whoever `Config.Admin.View` allows        | Opens the staff dashboard                                                |
| `lost_treasure_stats [server id or identifier]` | Console, or staff in game                 | A player's credits, rounds, wagered, won, net, inserted and cashed out   |
| `lost_treasure_bank`                            | Console, or staff in game                 | The house ledger: total wagered, paid, net, retained and pool            |
| `lost_treasure_replay <seed> [bet]`             | Console, or staff in game                 | Runs a round again from its seed. Only exists while `Config.Debug` is on |

## Renaming commands

| Command                | Setting                | File                       |
| ---------------------- | ---------------------- | -------------------------- |
| `/slot`                | `Config.Command`       | `config/config.lua`        |
| `/lost_treasure_admin` | `Config.Admin.Command` | `config/server/admin.lua`  |
| `lost_treasure_stats`  | `Config.StatsCommand`  | `config/server/server.lua` |
| `lost_treasure_bank`   | `Config.Bank.Command`  | `config/server/bank.lua`   |
| `lost_treasure_replay` | `Config.ReplayCommand` | `config/server/server.lua` |

## Permissions

| Ace                        | Grants                                                                                                   |
| -------------------------- | -------------------------------------------------------------------------------------------------------- |
| `lost_treasure.debug`      | Staff: the console commands in game, play during maintenance, the debug tools while `Config.Debug` is on |
| `lost_treasure.admin`      | Opening the staff dashboard                                                                              |
| `lost_treasure.admin.edit` | Changing the retention in the staff dashboard                                                            |

```cfg
add_ace group.admin lost_treasure.debug allow
add_ace group.admin lost_treasure.admin allow
add_ace group.admin lost_treasure.admin.edit allow
```

Framework groups and jobs can be used instead of aces. See [Staff dashboard](/organized-chaos-docs/the-lost-treasure/staff-dashboard.md) and [Security and maintenance](/organized-chaos-docs/the-lost-treasure/security-and-maintenance.md).

## Convars

Set these in your `server.cfg`. All three are optional.

| Convar                                 | Purpose                                       |
| -------------------------------------- | --------------------------------------------- |
| `lost_treasure_discord_webhook`        | The webhook of the private staff log          |
| `lost_treasure_discord_public_webhook` | The webhook of the public big-win feed        |
| `lost_treasure_rng_secret`             | An extra secret mixed into the random numbers |

## Exports

The exports are in two files that are left open, not encrypted: `server/exports.lua` and `client/exports.lua`. You can read them, change them and add exports of your own. Keep your version of them when you update the resource.

### Server exports

| Export                       | Returns                 | What it does                                                                                                                                                                           |
| ---------------------------- | ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `getPlayerStats(identifier)` | a table, or `nil`       | One player's lifetime figures: `credits`, `rounds`, `wagered`, `won`, `net`, `lost`, `deposited`, `cashedOut`, `biggestWin`. `nil` without a database, or with nothing stored for them |
| `getIdentifier(source)`      | an identifier, or `nil` | The identifier a connected player's figures are kept under, for `getPlayerStats`. `nil` if they have no character                                                                      |
| `getBankStats()`             | a table                 | The house ledger: `wagered`, `paid`, `net`, `retained`, `pool`, `float`, `rounds`, `redrawn`, `refused`, `rtp` (0 to 1), `retainPercent`, `enforcing`                                  |
| `isPlaying(source)`          | `true` or `false`       | Whether a player has a machine open right now                                                                                                                                          |
| `simulateRound(bet, seed)`   | a round                 | A round with no player and no money involved, for balance checks. `seed` is optional and repeats a round                                                                               |

```lua
-- In a server script of another resource
local identifier = exports.lost_treasure:getIdentifier(source)
local stats = identifier and exports.lost_treasure:getPlayerStats(identifier)
if stats then
    print(('%d rounds, %.2f wagered, %.2f won'):format(stats.rounds, stats.wagered, stats.won))
end

local bank = exports.lost_treasure:getBankStats()
local result = exports.lost_treasure:simulateRound(1.00)
```

### Client exports

| Export     | Returns           | What it does                                |
| ---------- | ----------------- | ------------------------------------------- |
| `isOpen()` | `true` or `false` | Whether the game is on this player's screen |

```lua
-- In a client script of another resource: no inventory at the machine
if exports.lost_treasure:isOpen() then return end
```

The exports use the resource name, which is why the folder has to be called `lost_treasure`.
