> ## Documentation Index
> Fetch the complete documentation index at: https://nonkit.rlaneth.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Yarn Reference

> Overview of Yarn commands and functions for NONMP

This reference documents the commands and functions available when writing Yarn scripts for NONMP using nonkit.

<Warning>
  **Disclaimer**: These command and function descriptions are based on analysis of the game's early releases. Some behaviors and parameter descriptions are inferred and may not be fully accurate. Furthermore, as NONMP is still in active Early Access development and receives frequent patches, the behavior of these functions may be inaccurate or subject to change.
</Warning>

## Categories

<CardGroup cols={2}>
  <Card title="Visual Commands" icon="image" href="/yarn-reference/visual-commands">
    Control backgrounds, characters, CGs, and visual effects.
  </Card>

  <Card title="Game Commands" icon="gamepad" href="/yarn-reference/game-commands">
    Manage battles, events, items, gold, time, and audio.
  </Card>

  <Card title="Functions" icon="function" href="/yarn-reference/functions">
    Query player attributes, game state, and localization.
  </Card>
</CardGroup>

## Command Syntax

Commands are wrapped in `<<>>` and can take parameters:

```yarn theme={null}
<<command_name>>
<<command_name param1>>
<<command_name param1 param2 123>>
```

Parameters can be:

* **Strings**: Usually unquoted (`BG-1`, `Lilith`), but some commands use quotes for specific parameters
* **Numbers**: `123`, `45.6`
* **Booleans**: `true`, `false`
* **Variables**: `$my_variable`
* **Coordinates**: `x,y` format like `0,0` or `-200,100`

## Function Syntax

Functions are called within expressions or inline text:

```yarn theme={null}
// In conditions
<<if get_gold() >= 100>>

// In set statements
<<set $health = get_player_attribute("HP")>>

// In dialogue (with curly braces)
Shopkeeper: You have {get_gold()} gold.
```

## Common Patterns

### Starting a Scene

```yarn theme={null}
<<back_creat BG-1 false 0,0 1 0>>
<<char_creat Lilith 1 1 false 0,0 0.7 0 0.3>>
<<set_bgm bgm_1>>
```

### Ending a Scene

```yarn theme={null}
<<char_remove Lilith>>
<<event_end>>
```

### Conditional Dialogue

```yarn theme={null}
<<if get_gold() >= 100>>
    // This runs if the condition is true
<<else>>
    // This runs otherwise
<<endif>>
```

### Giving Rewards

```yarn theme={null}
<<change_gold 100>>
<<change_item 2007 1 true>>
<<change_affection 1001 10 true>>
```

## ID Conventions

Many commands and functions use numeric IDs:

| Type          | Example  | Description                        |
| ------------- | -------- | ---------------------------------- |
| Item IDs      | `12345`  | Reference specific inventory items |
| Event IDs     | `900001` | Map event identifiers              |
| Condition IDs | `900001` | Unlock condition references        |
| Place IDs     | `9`      | Map location identifiers           |

<Note>
  IDs are based on game data analysis. Use values from 900000+ for custom content to avoid conflicts.
</Note>

## Parameter Conventions

Most parameters in the game scripts are unquoted:

```yarn theme={null}
<<back_creat BG-1 false 0,0 1 0>>
<<char_creat Lilith 1 1 false 0,-1200 0.7 0 0.3>>
```

Some specific parameters may require quotes (like hex colors or messages):

```yarn theme={null}
<<back_tint Test1 true "FF0000">>
<<toast "Message text">>
```

When in doubt, refer to the specific command documentation or game script examples.

## Error Handling

Commands that fail typically:

* Do nothing silently
* Log errors to the BepInEx console
* Continue executing subsequent commands

Check the BepInEx console window for error messages during development.

## Browse Commands

<Columns cols={2}>
  <Card title="Visual Commands" icon="image" href="/yarn-reference/visual-commands">
    `back_creat`, `char_creat`, `cg_creat`, `blink`, and more.
  </Card>

  <Card title="Game Commands" icon="gamepad" href="/yarn-reference/game-commands">
    `start_battle`, `change_gold`, `next_day`, `set_bgm`, and more.
  </Card>
</Columns>

<Card title="Functions" icon="function" href="/yarn-reference/functions">
  `get_gold()`, `get_value()`, `get_player_attribute()`, `l10n()`, and more.
</Card>
