**Language / Langue :** [[fr:yaml:variables|FR]] | **EN** ====== Variables (YAML) ====== ===== Numeric Variables ===== vars: score: 0 hp: value: 10 description: "Health points" The description is shown when the player examines the variable or when it is attached to a permanent option. ===== Text Variables ===== text_vars: hero_name: value: "Adventurer" description: "Hero name" Use text variables in text with ''t_hero_name_t''. To wait for a free-form answer, add ''reply: true'' to a text or numeric variable. The player can then type the answer directly without using the ''reply'' command. Room names, aliases and known actions still take priority. vars: guess: value: 0 reply: true text_vars: hero_name: value: "Adventurer" reply: true A numeric answer is stored without displaying the technical variable-change message. Use an event to provide the feedback intended for the player. ===== Online Variables ===== online_vars: record_o: value: 0 description: "Best score" The name must end with ''_o''. Use it like any numeric variable: ''v_record_o_v''. The variable ''nb_parties_o'' exists automatically and is incremented when a game starts. ===== Room init: ===== init: - var: die value: "%=1:6" description: "Die roll result" - text_var: state value: "resting" description: "Current state" ===== Value Modifiers ===== ^ Syntax ^ Effect ^ | ''0'' | Set to 0. | | ''"+1"'' | Add 1. | | ''"-3"'' | Subtract 3. | | ''"%=1:6"'' | Random from 1 to 6. | | ''"%+1:3"'' | Add random from 1 to 3. | | ''"%=v_min_v:v_max_v"'' | Random using variables as bounds. | ===== In Text ===== * ''v_name_v'' displays a numeric variable. * ''t_name_t'' displays a text variable. * ''v_turn_v|pad2'' displays the value padded to 2 digits. ===== System variables ===== ^ Variable ^ Value ^ | ''v_resultat_v'' | Result of the last ''%=X:Y'' random draw | | ''v_valeur_v'' | Last code entered through ''go room code'' | | ''v_reponse_v'' | Value entered with ''reply'' | | ''v_timer_name_v'' | Seconds left on the ''timer_name'' timer | These names stay in French, even in an English scenario: the engine reads them itself. ===== Display formatting ===== A numeric variable can be padded with ''|padN'': text: "Turn: v_turn_v|pad2" # shows "Turn: 07" when turn = 7 ===== A common trap with online variables ===== ⚠ The text of an event is evaluated **before** the action of that same event. To display the **new** value of a record, show the source variable, not the destination: events: - if: "v_score_v > v_record_o_v" do: "record_o.=.v_score_v" # Shows v_score_v (the source), not v_record_o_v (not updated yet) text: "New record: v_score_v (previous: v_record_o_v)"