FolioTier 1
when
Conditionally run a body of inline steps in place — non-routing alternative to `if`.
Parameters
| Parameter | Kind | Required | Default | Notes |
|---|---|---|---|---|
| condition | expression | yes | — | Bounded expression evaluated against project state. Same grammar as `if` — bare identifier, `not <ident>`, comparison, `and` / `or`. When the condition is true, the body runs in order; when false, the body is skipped and the scene continues past the `when` block. |
| body | identifier | yes | — | One or more indented Folio statements (say / narrate / show / hide / scene / set / gain stat / music / sound / ...). Each line inherits the `when`'s condition under the hood, so a body line with its own `if` tail evaluates both — but in practice you write the gate once at the `when` header. |
Canonical example
when day2-basketball:
show day20-dylan-amber 189
say "Sa": "I just can't approve that."
show day20-dylan-amber 190
say "Dy": "She wouldn't have missed a basket."if day2_basketball:
show day20_Dylan_Amber 189
sa "I just can't approve that."
show day20_Dylan_Amber 190
dy "She wouldn't have missed a basket."when is the non-routing sibling of if. The header when <condition>: opens a block; each indented line is a step that runs
only when the condition evaluates truthy. The scene continues past the
when block either way — falsy conditions skip the body without
branching anywhere.
Use when when a Ren'Py-style if X: is wrapping a few inline lines
that should fire conditionally inside the current scene. Use if
when the conditional outcome is to jump to a different scene.
Notes
The condition follows the same closed grammar as
if — bare identifier, not <ident>, comparison
with a bool/numeric literal, or and / or combinations. The
importer's deterministic stage only translates the conservative subset
(no compound and / or, no method calls, no dotted accessors);
unsupported shapes fall through to the AI lane rather than dropping
the guard.
Nesting works the same way if would in Ren'Py: a when inside a
when evaluates both conditions before running the inner body. The
runtime expands these at scene-load time so the player's step cursor
never has to descend — each child step's effective condition is the
AND of every surrounding when.
when day-saturday:
when invited-to-party:
scene party_bg
say "Mc": "I made it."
The importer maps Ren'Py's if <expr>: with an inline body (no elif
/ no else) to a Folio when block on a per-fragment basis (Gap 1,
Phase 8). Multi-branch if / elif / else chains stay in the AI
lane until Gap 4 ships — when it does, those will lower to nested
if routing rather than nested when blocks
because routing semantics differ from inline-body semantics.