en:yaml:variables
Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédente | |||
| en:yaml:variables [2026/08/31 20:56] – Wiki : fins de pages homogènes, liens Discord retirés cyrilfiesta | en:yaml:variables [2026/09/26 03:42] (Version actuelle) – documentation 4.15 : succès, variables persistantes et exports cyrilfiesta | ||
|---|---|---|---|
| Ligne 3: | Ligne 3: | ||
| ====== Variables (YAML) ====== | ====== Variables (YAML) ====== | ||
| - | ===== Numeric Variables | + | ===== Declaring variables |
| + | |||
| + | Numeric variables belong in '' | ||
| <code yaml> | <code yaml> | ||
| vars: | vars: | ||
| score: 0 | score: 0 | ||
| - | |||
| hp: | hp: | ||
| value: 10 | value: 10 | ||
| Ligne 14: | Ligne 15: | ||
| </ | </ | ||
| - | The description is shown when the player examines the variable or when it is attached to a permanent option. | + | Text variables belong in '' |
| - | + | ||
| - | ===== Text Variables ===== | + | |
| <code yaml> | <code yaml> | ||
| Ligne 25: | Ligne 24: | ||
| </ | </ | ||
| - | Use text variables in text with '' | + | The description is shown when the player examines the variable or when it is attached to a permanent option. |
| - | To wait for a free-form answer, add '' | + | ===== Scope: regular, persistent or online ===== |
| + | |||
| + | The suffix in the variable name determines its scope. All three kinds still belong in '' | ||
| + | |||
| + | ^ Name ^ Scope ^ Storage ^ | ||
| + | | '' | ||
| + | | '' | ||
| + | | '' | ||
| <code yaml> | <code yaml> | ||
| + | id: my-scenario | ||
| + | |||
| vars: | vars: | ||
| - | | + | |
| - | value: 0 | + | |
| - | reply: true | + | |
| text_vars: | text_vars: | ||
| - | | + | |
| - | value: "Adventurer" | + | |
| - | reply: true | + | |
| </ | </ | ||
| - | A numeric answer | + | '' |
| - | ===== Online | + | ===== Persistent _p variables ===== |
| + | |||
| + | A '' | ||
| + | |||
| + | A root '' | ||
| + | |||
| + | An existing value is loaded when the scenario starts. The first fixed assignment in '' | ||
| + | |||
| + | **Reset** clears the current scenario' | ||
| + | |||
| + | ===== Online | ||
| + | |||
| + | An '' | ||
| <code yaml> | <code yaml> | ||
| - | online_vars: | + | vars: |
| - | | + | |
| value: 0 | value: 0 | ||
| - | description: | + | description: |
| </ | </ | ||
| - | The name must end with '' | + | '' |
| - | The variable '' | + | ===== Variables in init: ===== |
| - | ===== Room init: ===== | + | '' |
| <code yaml> | <code yaml> | ||
| Ligne 62: | Ligne 81: | ||
| - var: die | - var: die | ||
| value: " | value: " | ||
| - | description: | + | description: |
| - text_var: state | - text_var: state | ||
| value: " | value: " | ||
| - | description: | ||
| </ | </ | ||
| - | ===== Value Modifiers ===== | + | A relative operation on an unknown name starts from 0. Giving the variable an explicit initial value first is usually clearer. |
| - | ^ Syntax ^ Effect ^ | + | ===== Free-form answers ===== |
| - | | '' | + | |
| - | | ''" | + | |
| - | | ''" | + | |
| - | | ''" | + | |
| - | | ''" | + | |
| - | | ''" | + | |
| - | ===== In Text ===== | + | Add '' |
| - | * '' | + | <code yaml> |
| - | | + | text_vars: |
| - | | + | hero_name: |
| + | value: " | ||
| + | reply: true | ||
| + | </ | ||
| + | |||
| + | Room names, aliases and known actions still take priority. A numeric answer is stored without a technical message; use an event to show the feedback intended for the player. | ||
| + | |||
| + | ===== Value modifiers ===== | ||
| + | |||
| + | ^ Syntax ^ Effect ^ | ||
| + | | '' | ||
| + | | '' | ||
| + | | ''" | ||
| + | | ''" | ||
| + | | ''" | ||
| + | | '' | ||
| - | ===== System variables ===== | + | ===== System variables |
| ^ Variable ^ Value ^ | ^ Variable ^ Value ^ | ||
| - | | '' | + | | '' |
| | '' | | '' | ||
| | '' | | '' | ||
| | '' | | '' | ||
| - | These names stay in French, even in an English scenario: the engine reads them itself. | + | These system |
| - | + | ||
| - | ===== Display formatting ===== | + | |
| - | + | ||
| - | A numeric variable can be padded with '' | + | |
| - | + | ||
| - | <code yaml> | + | |
| - | text: "Turn: v_turn_v|pad2" | + | |
| - | </ | + | |
| - | ===== A common trap with online variables | + | ===== A common trap ===== |
| - | ⚠ The text of an event is evaluated **before** the action | + | Event text is prepared |
| - | To display the **new** value of a record, | + | |
| <code yaml> | <code yaml> | ||
| Ligne 111: | Ligne 129: | ||
| - if: " | - if: " | ||
| do: " | do: " | ||
| - | | + | text: "New record: v_score_v" |
| - | | + | |
| </ | </ | ||
en/yaml/variables.txt · Dernière modification : de cyrilfiesta
