> ## 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.

# Functions

> Query player attributes, game state, and localization

Functions return values from the game. Use them in conditions, expressions, and dialogue text.

<Warning>
  These function signatures are based on analysis of the game's files. Some behaviors and parameter descriptions are inferred and may not be fully accurate. Furthermore, the game is in Early Access and may change over time.
</Warning>

## Usage Syntax

Functions can be used in several contexts:

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

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

// In dialogue text (use curly braces)
Player gold: {get_gold()}
```

## Player State Functions

### get\_player\_attribute

Returns a player attribute value.

```yarn theme={null}
get_player_attribute("HP")
get_player_attribute("STR")
```

| Parameter | Type   | Description    |
| --------- | ------ | -------------- |
| `name`    | string | Attribute name |

**Returns:** `float`

Common attributes: `"HP"`, `"MaxHP"`, `"STR"`, `"DEX"`, `"INT"`

```yarn theme={null}
<<if get_player_attribute("HP") < get_player_attribute("MaxHP") / 2>>
    Healer: You look injured.
<<endif>>
```

### get\_value

Retrieves a stored game value by ID.

```yarn theme={null}
get_value(1001)
```

| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `id`      | int  | Value ID    |

**Returns:** `float`

<Warning>
  This function takes an **integer ID**, not a string key. Value IDs are defined in the game's data tables.
</Warning>

```yarn theme={null}
<<if get_value(1001) == 1>>
    NPC: I see you've already started the quest.
<<endif>>
```

### get\_gold

Returns the player's current gold amount.

```yarn theme={null}
get_gold()
```

**Returns:** `int`

```yarn theme={null}
Merchant: You have {get_gold()} gold coins.

<<if get_gold() >= 500>>
    -> Buy the rare sword
<<endif>>
```

### get\_item

Returns the quantity of a specific item.

```yarn theme={null}
get_item(10001)
```

| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `itemID`  | int  | Item ID     |

**Returns:** `int`

```yarn theme={null}
<<if get_item(10001) >= 3>>
    Alchemist: You have enough herbs.
<<endif>>
```

### get\_item\_count

Alternative function to get item quantity.

```yarn theme={null}
get_item_count(10001)
```

| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `itemId`  | int  | Item ID     |

**Returns:** `int`

## Character Functions

Character functions use integer IDs to identify characters:

| ID   | Character    |
| ---- | ------------ |
| 1000 | Protagonist  |
| 1001 | Lilith (莉莉丝) |
| 1002 | Karen (卡莲)   |
| 1003 | Sartre (夏特露) |
| 1004 | Fouco (弗子)   |
| 1005 | Green (格林)   |

### get\_character\_attribute

Returns an attribute for a specific character.

```yarn theme={null}
get_character_attribute(1001, "HP")
```

| Parameter  | Type   | Description    |
| ---------- | ------ | -------------- |
| `id`       | int    | Character ID   |
| `attrName` | string | Attribute name |

**Returns:** `float`

<Warning>
  The first parameter is an **integer** character ID, not a string name.
</Warning>

```yarn theme={null}
<<if get_character_attribute(1001, "HP") < 50>>
    // Lilith is low on health
<<endif>>
```

### get\_char\_attr

Alias for `get_character_attribute`.

```yarn theme={null}
get_char_attr(1001, "STR")
```

| Parameter     | Type   | Description    |
| ------------- | ------ | -------------- |
| `characterID` | int    | Character ID   |
| `attr`        | string | Attribute name |

**Returns:** `float`

### is\_character\_dead

Checks if a character is dead.

```yarn theme={null}
is_character_dead(1003)
```

| Parameter | Type | Description  |
| --------- | ---- | ------------ |
| `id`      | int  | Character ID |

**Returns:** `bool`

```yarn theme={null}
<<if is_character_dead(1003)>>
    Lilith: We lost Sartre in that battle...
<<endif>>
```

### is\_own\_character

Checks if a character is in the player's party.

```yarn theme={null}
is_own_character(1003)
```

| Parameter | Type | Description  |
| --------- | ---- | ------------ |
| `id`      | int  | Character ID |

**Returns:** `bool`

```yarn theme={null}
<<if is_own_character(1003)>>
    -> Ask Sartre for help
<<endif>>
```

## Event Functions

### is\_event\_finished

Checks if a specific event has been completed.

```yarn theme={null}
is_event_finished(10084)
```

| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `eventID` | int  | Event ID    |

**Returns:** `bool`

```yarn theme={null}
<<if is_event_finished(10084)>>
    NPC: I heard you helped the merchant.
<<endif>>
```

## Global State Functions

### get\_global\_value

Retrieves a global game state value.

```yarn theme={null}
get_global_value("CurrentDay")
get_global_value("CurrentPeriod")
```

| Parameter | Type   | Description       |
| --------- | ------ | ----------------- |
| `name`    | string | Global value name |

**Returns:** `string`

```yarn theme={null}
Day {get_global_value("CurrentDay")}
```

### g\_str

Gets a global string value.

```yarn theme={null}
g_str("SomeStringValue")
```

| Parameter | Type   | Description |
| --------- | ------ | ----------- |
| `name`    | string | Value name  |

**Returns:** `string`

### g\_num

Gets a global numeric value.

```yarn theme={null}
g_num("SomeNumericValue")
```

| Parameter | Type   | Description |
| --------- | ------ | ----------- |
| `name`    | string | Value name  |

**Returns:** `float`

## Localization Function

### l10n

Retrieves a localized string by key.

```yarn theme={null}
l10n("UI_Confirm")
```

| Parameter | Type   | Description      |
| --------- | ------ | ---------------- |
| `key`     | string | Localization key |

**Returns:** `string`

<Note>
  **Standard dialogue localization** uses `#line:id` tags, not this function. The `l10n` function is for accessing the game's internal localization table (e.g., UI strings).
</Note>

## Cooking Functions

These functions are specific to the cooking system.

### has\_food\_ingredient

Checks if player has food ingredients.

```yarn theme={null}
has_food_ingredient()
```

**Returns:** `bool`

### get\_cook\_character

Gets the current cooking character.

```yarn theme={null}
get_cook_character()
```

**Returns:** `int` (character ID)

### get\_cook\_character\_dialog

Gets cooking dialogue for a character.

```yarn theme={null}
get_cook_character_dialog(1)
```

| Parameter | Type | Description   |
| --------- | ---- | ------------- |
| `type`    | int  | Dialogue type |

**Returns:** `string`

## Common Patterns

### Conditional Dialogue Based on Stats

```yarn theme={null}
<<if get_player_attribute("INT") >= 15>>
    -> [Intelligence] I notice something hidden...
<<endif>>

<<if get_player_attribute("STR") >= 12>>
    -> [Strength] I'll force it open.
<<endif>>
```

### Inventory Checks

```yarn theme={null}
<<if get_item(20001) >= 1>>
    Guard: Ah, you have the seal. Pass.
    <<change_item 20001 -1>>
<<else>>
    Guard: No entry without authorization.
<<endif>>
```

### Gold Checks

```yarn theme={null}
Merchant: That costs 50 gold. You have {get_gold()}.

<<if get_gold() >= 50>>
    -> Pay 50 gold
        <<change_gold -50>>
        <<change_item 10001 1>>
<<endif>>
-> I'll come back later
```

### Character State

```yarn theme={null}
<<if is_own_character(1003) && !is_character_dead(1003)>>
    -> Ask Sartre for advice
<<endif>>
```

### Event Progression

```yarn theme={null}
<<if is_event_finished(10001)>>
    NPC: Thank you for your help before!
<<else>>
    NPC: I could use some assistance...
<<endif>>
```

## Important Notes

<Warning>
  **Common mistakes:**

  * `get_value` takes an **int ID**, not a string
  * Character functions take **int IDs**, not string names
  * Use `#line:id` tags for dialogue localization, not `l10n()`
</Warning>

## Related Pages

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

  <Card title="Game Commands" icon="gamepad" href="/yarn-reference/game-commands">
    Modify game state with commands.
  </Card>
</CardGroup>
