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

# Games: Logic

### WireCut

A bundle of wires and one clue. The clue is one of three kinds: cut wires **in a given order**, cut wires **by position** from the top, or cut **everything except** some colours. Cutting the wrong wire is a mistake.

**Controls:** mouse

```lua
exports['sbminigames']:WireCut({ wires = 6, cutCount = 4, mistakes = 2, time = 25 }, cb)
```

Positional: `WireCut(wires, cutCount, time, callback)`

| Option     | Type | Default | Range                | What it does                            |
| ---------- | ---- | ------- | -------------------- | --------------------------------------- |
| `wires`    | int  | `5`     | 3 to 6               | Wires in the bundle                     |
| `cutCount` | int  | `3`     | 2 to `wires` minus 1 | Wires that must be cut                  |
| `mistakes` | int  | `2`     | 1 to 3               | Wrong cuts that end the game            |
| `time`     | int  | `20`    | 0 to 600             | Seconds before failing (`0` = no limit) |

### MineField

Classic minesweeper. Numbers show how many mines touch a tile. The first click is always safe. Open every safe tile to win.

**Controls:** click to open, right-click to flag

```lua
exports['sbminigames']:MineField({ gridSize = 5, mines = 5, time = 60 }, cb)
```

Positional: `MineField(gridSize, mines, time, callback)`

| Option     | Type | Default | Range                            | What it does                            |
| ---------- | ---- | ------- | -------------------------------- | --------------------------------------- |
| `gridSize` | int  | `4`     | 3 to 6                           | Grid is `gridSize` by `gridSize`        |
| `mines`    | int  | `3`     | 1 to `gridSize` squared, minus 1 | Hidden mines                            |
| `time`     | int  | `0`     | 0 to 600                         | Seconds before failing (`0` = no limit) |

### CodeBreaker

Guess the secret digit code. After each guess, a filled peg means *right digit, right place*. A hollow peg means *right digit, wrong place*. Crack it before you run out of attempts.

**Controls:** digits, `Backspace`, `Enter`

```lua
exports['sbminigames']:CodeBreaker({ length = 4, attempts = 7, unique = true, time = 90 }, cb)
```

Positional: `CodeBreaker(length, attempts, time, callback)`

| Option     | Type | Default | Range         | What it does                            |
| ---------- | ---- | ------- | ------------- | --------------------------------------- |
| `length`   | int  | `4`     | 3 to 6        | Digits in the code                      |
| `attempts` | int  | `8`     | 4 to 12       | Guesses allowed                         |
| `unique`   | bool | `true`  | true or false | No repeated digits in the secret        |
| `time`     | int  | `0`     | 0 to 600      | Seconds before failing (`0` = no limit) |

### NumberOrder

Numbers are scattered across the board. Click them **in order, starting from 1**. With `scramble` on, the remaining numbers move to new places after every correct click.

**Controls:** mouse

```lua
exports['sbminigames']:NumberOrder({ count = 12, scramble = true, time = 20 }, cb)
```

Positional: `NumberOrder(count, time, callback)`

| Option     | Type | Default | Range         | What it does                                     |
| ---------- | ---- | ------- | ------------- | ------------------------------------------------ |
| `count`    | int  | `9`     | 4 to 16       | Numbers on the board                             |
| `scramble` | bool | `false` | true or false | Reshuffle the remaining numbers after each click |
| `lives`    | int  | `3`     | 1 to 5        | Wrong clicks allowed                             |
| `time`     | int  | `15`    | 0 to 600      | Seconds before failing (`0` = no limit)          |
