Outils pour utilisateurs

Outils du site


en:yaml:choix

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Prochaine révision
Révision précédente
en:yaml:choix [2026/05/03 18:29] – Add English wiki page using real engine keys cyrilfiestaen:yaml:choix [2026/10/19 21:20] (Version actuelle) – Textes des choix : tentative, resultat et ordre des effets cyrilfiesta
Ligne 1: Ligne 1:
-**Language:** [[fr:yaml:choix|Français]] | **English**+**Language / Langue :** [[fr:yaml:choix|FR]] | **EN**
  
 ====== Choices and Buttons (YAML) ====== ====== Choices and Buttons (YAML) ======
  
-Choices define navigation commands and buttons shown to the player.+Choices define the exits available from a room - navigation, access conditions and buttons shown to the player.
  
-===== Base Syntax =====+===== Minimal syntax ===== 
 + 
 +The simplest form: a destination, nothing else.
  
 <code yaml> <code yaml>
 choices: choices:
-  - command: north +  - to: forest 
-    button: "Go north"+  - to: village 
 +</code> 
 + 
 +The room ''forest'' is reachable by typing ''go forest''. No button is displayed. 
 + 
 +===== Adding a button ===== 
 + 
 +''button:'' displays a clickable button below the room text. 
 + 
 +<code yaml> 
 +choices: 
 +  - button: "⬆️ Go north"
     to: forest     to: forest
  
-  - command: back +  - button: "🏠 Back to village" 
-    to: home+    to: village
 </code> </code>
  
-  * ''command:'' — keyword the player can type. +===== Typed command =====
-  * ''button:'' — visible button label. If absent, no local button is shown unless a global alias provides one. +
-  * ''to:'' — destination room.+
  
-===== Button Defined on the Room =====+''command:'' defines a keyword the player can type (in addition to the button).
  
 <code yaml> <code yaml>
-- id: timers_demo +choices: 
-  button: "Timers" +  - command: north 
-  text: "..."+    button: "⬆️ Go north" 
 +    to: forest
 </code> </code>
  
-A choice pointing to this room without its own ''button:'' can inherit the room button.+The player can click the button **or** type ''north'' or ''go north''. Without ''command:'', use the destination id, for example ''go forest''. 
 + 
 +With [[en:yaml:texte#listing_choices_in_the_text|choice lists in the text]], a choice without an alias uses its position in the list. An explicit numeric alias takes priority over a room number or an automatic button shortcut. 
 + 
 +See [[en:yaml:alias|Aliases and commands]] for global shortcuts and action aliases. 
 + 
 +===== Button inherited from the room ===== 
 + 
 +If the destination room has a ''button:'', choices pointing to it without their own ''button:'' inherit that label automatically. 
 + 
 +<code yaml> 
 +rooms: 
 +  - id: laboratory 
 +    button: "⚗️ Laboratory" 
 +    text: "..." 
 + 
 +  - id: corridor 
 +    choices: 
 +      - to: laboratory    # displays "⚗️ Laboratory" without repeating it here 
 +</code>
  
 ===== to: previous ===== ===== to: previous =====
 +
 +''to: previous'' returns to the room the player came from.
  
 <code yaml> <code yaml>
 choices: choices:
   - command: back   - command: back
-    button: "Back"+    button: "↩️ Back"
     to: previous     to: previous
 </code> </code>
  
-===== Access Conditions =====+===== Access condition (if:) ===== 
 + 
 +''text:'' describes the attempt, including when ''if:'' fails. ''text_ok:'' and ''text_ko:'' describe the result of that condition.
  
 <code yaml> <code yaml>
 choices: choices:
   - command: enter   - command: enter
-    button: "Enter the secret room"+    button: Enter
     to: secret_room     to: secret_room
-    if: "key v_score_v > 10" +    text: "You push the door." 
-    text_ko: "The door remains closed."+    if: "key" 
 +    text_ok: "The lock gives way." 
 +    text_ko: "The door stays locked."
 </code> </code>
  
-===== Conditional Buttons =====+^ Situation ^ Texts shown ^ Effect and movement ^ 
 +| No ''if:'' | ''text'' | Yes | 
 +| Condition passes | ''text'' and ''text_ok'' | Yes | 
 +| Condition fails | ''text'' and ''text_ko'' | No | 
 +| ''text_ok'' without ''if:'' | No OK text | Yes | 
 +| Disabled button | None | No | 
 + 
 +Texts follow their order in the YAML. In the editor, use the move buttons beside the text fields to change that order; a new choice starts with the Text field. 
 + 
 +''effect:'' runs after checking ''if:'', before the texts and movement. Texts therefore read the values updated by the effect, even when ''effect:'' is written after them. 
 + 
 +This rule applies to choices. An action uses ''text_ok:'' on success, including without a condition. An event uses ''text:'' when it runs; that text is not shown when its condition fails. 
 + 
 +===== Conditional button (visible-if / disabled-if) =====
  
 <code yaml> <code yaml>
 choices: choices:
   - command: expert   - command: expert
-    button: "Expert mode"+    button: "🏆 Expert mode"
     to: expert_room     to: expert_room
-    visible-if: "v_score_v > 50"+    visible-if: "v_score_v > 50"    # button hidden if score <= 50
  
-  - command: weakened +  - command: move 
-    button: "Move on"+    button: "💀 Move on"
     to: next_room     to: next_room
-    disabled-if: "v_hp_v <= 0"+    disabled-if: "v_hp_v <= 0"      # button visible but inactive if HP = 0
 </code> </code>
  
-===== Click Effect =====+  * ''visible-if:'' - the button disappears if the condition is false 
 +  * ''disabled-if:'' - the button stays visible but cannot be clicked
  
-''effect:'' runs before moving to the destination.+===== Click effect (effect:) ===== 
 + 
 +''effect:'' runs an action **before** moving to the destination.
  
 <code yaml> <code yaml>
 choices: choices:
   - command: buy   - command: buy
-    button: "Buy (-10 gold)"+    button: "🪙 Buy (-10 gold)"
     to: shop     to: shop
-    effect: "gold.-.10" 
     if: "v_gold_v >= 10"     if: "v_gold_v >= 10"
 +    effect: "gold.-.10"
 </code> </code>
  
-===== Clear HUD on Click =====+===== Clear HUD on click =====
  
 <code yaml> <code yaml>
 choices: choices:
   - command: back   - command: back
-    button: "Back"+    button: "↩️ Back"
     to: home     to: home
     clear-hud:     clear-hud:
en/yaml/choix.1777825786.txt.gz · Dernière modification : de cyrilfiesta