> For the complete documentation index, see [llms.txt](https://kazescripts.gitbook.io/kazescripts/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kazescripts.gitbook.io/kazescripts/kaze_lib/minigames.md).

# Minigames

7 minigames with easy, medium and hard levels.

All minigame exports are **client side**. Each one opens the minigame with the mouse, waits until it ends and returns `true` when won, `false` when lost, given up with Esc, or when another minigame is already open.

## Level

`level` is `'easy'`, `'medium'` (default) or `'hard'`, or a number from `1` to `5`.

| Level      | Difficulty | Time |
| ---------- | ---------- | ---- |
| `'easy'`   | 1          | 130% |
| `'medium'` | 3          | 100% |
| `'hard'`   | 5          | 80%  |

Change these in `MinigameLevels` in `kaze_lib/config.lua`.

## Exports

| Export                                  | Minigame                                                | Settings (defaults)           |
| --------------------------------------- | ------------------------------------------------------- | ----------------------------- |
| `RelayHack(level, settings, meta)`      | Match the signal wave and hold it                       | `Time = 25`, `HoldTime = 1.6` |
| `Hotwire(level, settings, meta)`        | Connect the ignition wires                              | `Time = 35`, `Penalty = 3`    |
| `CuttingTorch(level, settings)`         | Follow the cut line with the torch                      | `Time = 30`                   |
| `WheelNuts(level, settings)`            | Loosen the nuts in a star pattern by circling the mouse | `Nuts = 5`, `Strikes = 3`     |
| `WireCutters(level, settings)`          | Cut the right wires                                     | `Wires = 5`, `Time = 20`      |
| `PipeSaw(level, settings)`              | Keep the saw in the sweet spot                          | `Time = 25`                   |
| `EngineRemoval(level, settings)`        | Unplug, unbolt and lift the engine                      | `Bolts = 4`, `Time = 35`      |
| `Minigame(kind, level, settings, meta)` | Any of the above by name                                |                               |
| `IsMinigameActive()`                    | Returns `true` while a minigame is open                 |                               |

| Parameter  | Type             | Description                                                                      |
| ---------- | ---------------- | -------------------------------------------------------------------------------- |
| `level`    | string or number | See Level above                                                                  |
| `settings` | table            | Optional. Overrides the defaults above                                           |
| `meta`     | table            | Optional. Extra info shown in the minigame, for example `{ plate = '42KZT731' }` |
| `kind`     | string           | `'relay'`, `'wiring'`, `'torch'`, `'wrench'`, `'wires'`, `'saw'` or `'hoist'`    |

Default settings for every minigame are in `Minigames` in `kaze_lib/config.lua`.

## Examples

```lua
local won = exports.kaze_lib:RelayHack('medium', nil, { plate = '42KZT731' })
local won = exports.kaze_lib:Hotwire('easy')
local won = exports.kaze_lib:CuttingTorch(4)
local won = exports.kaze_lib:WheelNuts('hard', { Nuts = 6 })
local won = exports.kaze_lib:WireCutters('easy')
local won = exports.kaze_lib:PipeSaw('medium')
local won = exports.kaze_lib:EngineRemoval('hard')
local won = exports.kaze_lib:Minigame('torch', 'hard')

if exports.kaze_lib:IsMinigameActive() then return end
```

```lua
-- A full example: remove a wheel
local won = exports.kaze_lib:WheelNuts('medium')
if won then
    exports.kaze_lib:Notify('Wheel off.', 'success')
else
    exports.kaze_lib:Notify('The wrench slipped.', 'error')
end
```
