en:yaml:modeles
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:modeles [2026/10/18 22:48] – Documentation 4.17 : listes, boucles, raccourcis et editeur cyrilfiesta | en:yaml:modeles [2026/10/20 22:23] (Version actuelle) – Modèles sur_place, portée des encadrés et objets 4.17 cyrilfiesta | ||
|---|---|---|---|
| Ligne 3: | Ligne 3: | ||
| ====== Models (YAML) ====== | ====== Models (YAML) ====== | ||
| - | Models are reusable | + | A model contains |
| - | ===== Declare | + | ===== Example: |
| + | |||
| + | This scenario opens the model, lets the player heal, then returns to the calling room's choices. | ||
| <code yaml> | <code yaml> | ||
| + | title: Infirmary | ||
| + | vars: | ||
| + | hp: 10 | ||
| models: | models: | ||
| - | | + | |
| variables: | variables: | ||
| - | | + | |
| - | exits: | + | |
| - | victory: victory | + | |
| - | defeat: defeat | + | |
| rooms: | rooms: | ||
| - | - id: attack | + | - id: sheet |
| - | text: "You attack!" | + | text: ' |
| - | | + | |
| - | - if: " | + | actions: |
| - | | + | - verb: heal |
| - | - if: ~ | + | |
| - | do: " | + | |
| - | to: enemy_turn | + | do: health + 5 |
| - | + | choices: | |
| - | - id: enemy_turn | + | |
| - | text: "The enemy retaliates." | + | to: end_model |
| - | | + | rooms: |
| - | - if: " | + | - id: start |
| - | to: defeat | + | text: You enter the infirmary. |
| - | - if: ~ | + | models: |
| - | to: attack | + | - model: healing |
| + | | ||
| + | | ||
| + | choices: | ||
| + | | ||
| + | to: conclusion | ||
| + | - id: conclusion | ||
| + | | ||
| + | - end: victory | ||
| </ | </ | ||
| - | ===== Instantiate | + | The '' |
| - | <code yaml> | + | Internal rooms receive a prefix |
| - | - id: goblin_fight | + | |
| - | text: "A goblin appears!" | + | |
| - | models: | + | |
| - | - name: simple_fight | + | |
| - | variables: | + | |
| - | enemy_hp: goblin_hp | + | |
| - | exits: | + | |
| - | victory: after_fight | + | |
| - | defeat: game_over | + | |
| - | </ | + | |
| - | + | ||
| - | Internal rooms are automatically prefixed | + | |
| - | + | ||
| - | ===== See also ===== | + | |
| - | + | ||
| - | * [[en: | + | |
| - | * [[en: | + | |
| ===== Bound lists and collections (4.17) ===== | ===== Bound lists and collections (4.17) ===== | ||
| - | A model can declare generic lists and collections. | + | A model can declare generic lists and collections. |
| <code yaml> | <code yaml> | ||
| Ligne 66: | Ligne 59: | ||
| </ | </ | ||
| - | These fields belong in the model instance. Paths cross collections only, with no retained | + | Targets must exist. Paths cross collections only, without |
| + | |||
| + | See [[en: | ||
| + | |||
| + | ===== Adding a model to the current room: inline ===== | ||
| + | |||
| + | Set '' | ||
| + | |||
| + | <code yaml> | ||
| + | title: A model in the workshop | ||
| + | collections: | ||
| + | player: {} | ||
| + | models: | ||
| + | inline_healing: | ||
| + | inline: true | ||
| + | collections: | ||
| + | hero: {health: 0} | ||
| + | defaults: | ||
| + | hero: {health: 100} | ||
| + | rooms: | ||
| + | - id: content | ||
| + | hud: | ||
| + | position: top-right | ||
| + | scope: room | ||
| + | text: ' | ||
| + | actions: | ||
| + | - verb: heal | ||
| + | target: all | ||
| + | button: Heal | ||
| + | do: hero.health + 1 | ||
| + | rooms: | ||
| + | - id: workshop | ||
| + | text: You are in the workshop. | ||
| + | models: | ||
| + | - model: inline_healing | ||
| + | collections: | ||
| + | choices: | ||
| + | - {command: leave, to: corridor} | ||
| + | - id: corridor | ||
| + | text: The corridor. | ||
| + | choices: | ||
| + | - {command: return, to: workshop} | ||
| + | </ | ||
| + | |||
| + | Heal acts in the workshop and Leave remains available. Returning preserves '' | ||
| + | |||
| + | '' | ||
| + | |||
| + | '' | ||
| + | |||
| + | ===== Collection defaults ===== | ||
| + | |||
| + | The example' | ||
| + | |||
| + | The editor exposes inline insertion and defaults for each generic collection in the model definition. The French key is '' | ||
| + | |||
| + | The supplied library includes '' | ||
en/yaml/modeles.1792356507.txt.gz · Dernière modification : de cyrilfiesta
