Docs/Core concepts/The WHEN / IF / DO model
The WHEN / IF / DO model
Every behavior in Verse Builder is a rule: WHEN something happens, IF a condition is true, DO these actions. That is the entire vocabulary.
Last updated 2026-06-06
Anatomy of a rule
Rules live in the Rules tab of each device. They're ordered, and every rule has the same three slots:
WHEN <event>
IF <condition> # optional, defaults to "always"
DO <action 1>
<action 2>
...When the event fires, the rule first checks every IF condition; if all pass, the DO actions run top-to-bottom for the agent (player or device) that triggered the event.
WHEN — the trigger
A trigger is the event that wakes the rule up. Common ones:
On Begin— once, when the round starts.On Player Joined— fires per player joining.On Elimination— fires when one agent eliminates another.On Button Pressed,On Volume Entered,On Timer Elapsed— device-specific signals.
Every event carries the agent that caused it (usually the player). Your IFs and DOs receive that agent implicitly.
IF — the gate
IF is optional. If you omit it, the rule runs every time the event fires. With one or more conditions, the rule only runs if all of them are true.
Is in phase— only when the game is in a given phase.Compare variable— only whencoins ≥ 100.Has item— only when the agent holdsshield_potion.
💡 Tip
IF that runs continuously.DO — the actions
Actions are the side effects. They run in the order you list them. You can mix any combination — granting items, changing variables, showing HUD messages, teleporting.
Increment Variablecoins by10.Show HUD Messagewith text from a Message.Activate Deviceon a teleporter to teleport the agent.
Patterns
Branching by phase
Two rules on the same event, gated by different phases — that's how you switch behavior between lobby and game.
Rule A: WHEN On Player Joined IF Is in phase = lobby DO Teleport to lobby_spawn
Rule B: WHEN On Player Joined IF Is in phase = game DO Teleport to game_spawnSequencing actions
Actions in a single DO run top to bottom. Use this to chain reward + feedback + sound on a single event.
WHEN On Elimination
DO Increment Variable coins by 10
Show HUD Message "+10 coins"
Play Sound coin_pickupGating with a counter
Combine IF Compare variable with DO Set variable to build progression gates (level-up, unlock, …).
Gotchas
⚠️ Watch out
⚠️ Watch out
break. You can't stop a rule mid-DO. To skip actions conditionally, split into multiple rules with different IFs.📌 Note
What gets generated?
Each WHEN subscribes to an event on a device, runs the IF as a failable expression, and emits the DO actions inline:
# WHEN On Elimination DO Increment Variable coins by 10
EliminationManager.EliminatedEvent.Subscribe(OnElim)
OnElim(Agent:?agent):void=
if (Raw := Agent?):
SetCoins(Raw, GetCoins[Raw] + 10)
You don't write any of this — the Composer emits it from your rules, deterministically and the same way every time.
Open any rule
Switch to the Rules tab on any device and expand a rule. You'll see the three slots labeled WHEN / IF / DO.Peek the Verse output
Hit⌘ + .to peek the generated Verse code for the current device without leaving the rules editor.
See also