**Language / Langue :** [[fr:yaml:timers|FR]] | **EN** ====== Timers (YAML) ====== JDR-Bot provides several timing mechanics. ===== Visual Pause %%{{timer:N}}%% ===== text: | The mechanism starts... {{timer:3}} The door opens! ===== Local Timer ===== A local timer is declared in an event and is cancelled when the player leaves the room. events: - if: ~ timer: hourglass duration: "30" to: expired_room text: "Timer started: v_hourglass_v seconds left." ===== Global Timer ===== global_timers: - id: bomb duration: 60 state: OFF events: - if: ~ do: "timer_global:bomb:ON" Autonomous global timers can run their own actions when they expire: global_timers: - id: fatal_countdown duration: 60 state: OFF text: "Time is up!" do: - "score.-.20" to: defeat_end ===== tick: ===== ''tick:'' runs every second on local or global timers. events: - if: ~ timer: tick_demo duration: "180" to: expired_room tick: - if: ~ do: "ticks.+.1" - if: "v_ticks_v > 5" do: "other_var.+.1" On a global timer: global_timers: - id: poison_tick duration: 30 state: OFF tick: - if: "v_hp_v > 0" do: "hp.-.1" text: "The poison acts... (HP: v_hp_v)" * ''tick:'' runs independently of ''to:'' and ''do:'', which run when the timer expires. * Leaving the room cancels a local timer and its tick. * Calls through ''trigger_event:'' are limited to 10 nested levels, including from a tick. ===== Stopping a timer ===== A **local timer** cancels itself as soon as the player leaves the room: it belongs to that room. A **global timer** is stopped with the same switch that starts it: do: "timer_global:bomb:OFF" # pauses the timer Or: do: "timer_global:bomb:SWITCH" # toggles its state ''OFF'' keeps the remaining time: a later ''ON'' resumes where the timer stopped.