Concepts
Logic — when, if, do
How rules work in Cynario. Every rule is "WHEN a trigger [IF a condition] DO effects." The five triggers, the three effect families (Memory, Content, Context), the operator families, and how a click and an automatic rule settle in one bounded pass.
On this page
- The five “when ___” triggers
- “when you click this” is self-selecting
- “as soon as ___” is automatic — and it is a check, not a watcher
- ”if / while ___” is a gate, not a trigger
- Effects act on three families: Memory, Content, Context
- Conditions and operators
- How rules settle: one bounded pass
- In short
- Related pages
Logic is the rule layer of a Scene. A Scene is one markup-centric Scene source, and Logic is one of the abstractions embossed from it — not a separate layer stacked on top: Markup carries content and media, Bindings read state into that content, and Logic is where the rules — and every change to the run — live.
There is exactly one rule shape, and you read it as a plain English sentence:
WHEN a trigger [IF / WHILE a condition**] DO** effects.
For example:
WHEN you click Isolate the host IF trust is at least 3 DO add 5 to score, then go to the Calm ending.
You fill in the blanks from dropdowns. The trigger is when the rule fires, the optional condition is a gate that has to be open for it to act, and the effects are what it does. The rest of this page walks through each part.
The five “when ___” triggers
A trigger is the when that fires a rule. There are five kinds — four that fire, and one that only gates.
| Trigger | You write | Fires when |
|---|---|---|
| when you click this | when you click [Cut the cable] | the player activates this element or choice |
| when you arrive | when you arrive | the player enters this Scene |
| when you leave | when you leave | the player exits this Scene — no matter which path is taken |
as soon as <condition> becomes true | as soon as [power is at most 0] becomes true | a fact has just changed and the condition is now true — badged automatic |
if / while <condition> | if [trust is at least 3] | (a gate, not a trigger — see below) |
“when you click this” is self-selecting
A click belongs to one element. When the player clicks it, that rule runs — there is nothing to choose between, so a click never needs a priority. (Priority only matters for automatic rules; see How rules settle.)
“as soon as ___” is automatic — and it is a check, not a watcher
The fourth trigger fires by itself. You do not click it; it goes off the moment its condition
becomes true. Write it as “as soon as <condition> becomes true,” and the builder badges it
automatic so it reads differently from a click rule.
The important mental model: “as soon as” is a discrete check, not a live watcher. It is checked at the moment something happens — when you click, arrive, or leave — and not at every passing instant. So an effect that changes a fact can make an “as soon as” condition newly true, and the engine notices and acts on it right then, in the same pass, before anything is redrawn. Nothing is “watching” in the background.
Cut the cable, power drops to zero, and you land on the Blackout ending — in one motion — because the click’s effect (subtract 40 from power) makes the automatic rule’s condition (power is at most 0) true, and the automatic rule fires off the back of that change.
”if / while ___” is a gate, not a trigger
IF (and its standing-condition twin WHILE) does not fire anything. It is a gate: a
condition that has to be open for a rule to act. A trigger asks “did this just happen?”; a gate
asks “is this true right now?” You put a trigger in the WHEN slot and a condition in the
IF / WHILE slot — never the other way around.
Effects act on three families: Memory, Content, Context
The DO part of a rule is a list of effects. Every effect changes exactly one of three things — and that is the whole alphabet. There is nothing else an effect can touch.
| Family | Plain meaning | Effects read like |
|---|---|---|
| Memory | the facts the run remembers | set intel to true · add 5 to score · add laptop-A to picked · remove an item · flip a flag |
| Content | what is shown right now | show / hide a block · mark an element as correct / wrong / selected / muted · show a value in the text |
| Context | where you are in the scenario | go to a Scene · pick an ending (which is just go to a terminal Scene) |
A few notes that keep these straight:
- Memory is the only family that remembers anything. Setting a fact, nudging a number,
toggling a flag, or adding to a list all live here. A score is just a number you
addto — there is no separate “scoring” idea. - Content is what the player sees on the current Scene. Showing or hiding a block, marking an element with a token, or substituting a value into the prose are all Content effects.
- Context is where you are in the scenario — space- and time-neutral. The “go to” effect lives here, and picking an ending is just a “go to” into a terminal Scene. (Context is the settled word for this; you will never see “Location” on the author surface.)
Why exactly these three, and why “go to” and “show” leave nothing behind, is the subject of The truth model: only Memory is stored, and Content and Context are rebuilt every time from Memory and the playthrough log. You do not need that mechanism to author — the three families are all you fill in — but it is what makes undo, replay, and sharing work.
Conditions and operators
Both the IF / WHILE gate and the as soon as trigger use a condition — a plain-English true/false test you build from dropdowns. The same condition builder is reused everywhere a condition is asked for, so there is one thing to learn.
You build conditions and values from five tight families of operators — plain words, no symbols required, and no looping:
| Family | Words | For |
|---|---|---|
| Compare | is · is not · is more than · is less than · is at least · is at most | testing a value |
| Combine | and · or · not | joining tests |
| List | contains · is in · count · is empty | working with a list (including how many) |
| Math | add · subtract · multiply · divide · min · max | computing a value |
| Range | between (inclusive) | “between 2 and 4” |
A condition is just one true/false test asked at a single moment — there is no sequence or loop inside it. When you need to mix and with or, you put one of them in an indented group so the grouping itself shows the precedence; you never read a wall of parentheses.
How rules settle: one bounded pass
When something happens — a click, an arrival, a departure — Cynario runs all the rules that apply in one bounded pass, and then the Scene is drawn once. The player never sees a half-finished state mid-pass; they see only the settled result.
Two things decide the order, and they are the same setting:
- Default order is author order. Rules at the same trigger run top to bottom, the way you listed them. That is the only order you have to reason about by default.
- Priority is an optional override for automatic rules only. If two automatic rules could act at the same moment, the higher-priority one wins; ties fall back to author order. A click never carries a priority because a click is self-selecting — it already belongs to one element.
This same ordering also auto-routes: when several automatic “go to” rules could fire, the engine picks exactly one — highest priority, then author order, with an unconditional path as the fallback. The result is always one settled Scene.
The pass is bounded: an effect can make an automatic rule true, which can make another true, and the engine follows that chain forward — but only forward, each rule at most once, and only up to a hard limit. If a chain runs past the limit it stops and tells you, rather than looping forever. If you genuinely need a longer sequence — or you want the Scene to redraw between beats — split it across separate clicks or Scenes instead of trying to do it all in one pass.
In short
- Every rule is WHEN a trigger [IF / WHILE a condition] DO effects — fill-in-the-blank English.
- Five triggers: when you click this · when you arrive · when you leave · as soon as a condition becomes true (automatic) — plus if / while, which is a gate, not a trigger.
- Every effect changes exactly one of three families — Memory (facts), Content (what’s shown), or Context (where you are) — and that is the whole alphabet.
- Conditions and values come from five plain-word operator families — compare, combine, list, math, range — with no looping.
- One event runs all applicable rules in one bounded pass, ordered by author order (with optional priority for automatic rules), then draws once. A click selects itself.
Related pages
- The Scene (the Scene source) — the whole work, the unit you build, and the floor every Scene sits on (Bindings read, Logic writes).
- The truth model — the playthrough log is the single source of truth; Memory, Content, and Context are views rebuilt from it.
- Reuse and the Workspace Library — Logic Blocks, Components, and Blueprints, and how reusable rule packs are placed.