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édenteProchaine révision | Révision précédente | ||
| en:yaml:variables [2026/07/15 01:41] – maj 4.13 : modes d'interface + corrections cyrilfiesta | en:yaml:variables [2026/10/20 22:12] (Version actuelle) – Mod?les sur_place, port?e des encadr?s et objets 4.17 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 | ||
| + | |||
| + | For a scenario source authorised by the server, 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. |
| + | |||
| + | ===== Free-form answers ===== | ||
| + | |||
| + | In a room's '' | ||
| + | |||
| + | <code yaml> | ||
| + | init: | ||
| + | - text_var: 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 ^ | ^ Syntax ^ Effect ^ | ||
| - | | '' | + | | '' |
| - | | ''" | + | | ''" |
| - | | ''" | + | | ''" |
| - | | ''" | + | | ''" |
| - | | ''" | + | | ''" |
| - | | ''" | + | | ''" |
| + | |||
| + | ===== System variables and display ===== | ||
| + | |||
| + | ^ Variable ^ Value ^ | ||
| + | | '' | ||
| + | | '' | ||
| + | | '' | ||
| + | | '' | ||
| + | |||
| + | The system names above also work in English scenarios. For a declared '' | ||
| + | |||
| + | ===== A common trap ===== | ||
| + | |||
| + | Event text is prepared before the action from that same event. To announce a new record, display the source variable: | ||
| + | |||
| + | <code yaml> | ||
| + | events: | ||
| + | - if: " | ||
| + | do: " | ||
| + | text: "New record: v_score_v" | ||
| + | </ | ||
| + | |||
| + | ===== Paths and spaced effects (4.17) ===== | ||
| + | |||
| + | [[en: | ||
| + | |||
| + | In '' | ||
| + | |||
| + | <code yaml> | ||
| + | do: | ||
| + | - hero.health + 10 | ||
| + | - score + %1:6 | ||
| + | - score + %2: | ||
| + | </ | ||
| + | |||
| + | The last example draws 2 with weight 70 or 5 with weight 30. '' | ||
| + | |||
| + | '' | ||
| + | |||
| + | ===== Describing structured data ===== | ||
| - | ===== In Text ===== | + | Lists, collections, |
| - | * '' | + | In the editor, online variables remain grouped with numbers or text according to their type. Declare an '' |
| - | * '' | + | |
| - | * '' | + | |
en/yaml/variables.1784072519.txt.gz · Dernière modification : de cyrilfiesta
