Curly-brace blocks ({...}) handle variables, conditionals, and loops directly inside chapter content. Default variables are declared in the Variables Manager, but more variables can be added by your code during runtime.
Printing a variable
{$playerName}
Shorthand for printing a single variable. For more control, use print:
{print($playerName)}
{print($playerName, "the traveler")}
{print($playerName, fallback="the traveler")}
{print($playerName, fallback="the traveler", cap=true)}
- The first form prints the variable, or nothing if it's
undefined/null. - A second positional argument (or
fallback=) is shown instead when the variable is unset. cap=truecapitalizes the first letter of the result.
Setting a variable
{set($relationship, $relationship + 1)}
{set($playerName, "Sam")}
Writes straight through to the project's variable store (Store.Set, see Coding), so a Store.Register listener in a scene script sees the change immediately, and {$var} prints elsewhere reflect it on their next render.
Conditionals
{if ($metAlice == true)
Alice waves at you from across the room.
} else {
A stranger glances at you, then looks away.
}
The else block is optional. Conditions are evaluated as JS-like expressions (see "Expression syntax" below): comparisons, boolean logic, arithmetic, and ternaries all work.
Loops
{for ($i in range(0,3))
Item number {$i}
}
range(start, end)expands tostart, start+1, ..., end-1.- You can also loop over an actual array variable:
{for ($item in $inventory) ... }. - Looping over a plain number counts from
0up to, but not including, that number.
Logging from content
{log($someVariable)}
Prints the evaluated value to the console via the runtime logger. Handy for debugging a chapter without needing to jump into a scene script.
Expression syntax
Expressions (conditions, set values, loop ranges) support a restricted, JS-like grammar: arithmetic (+ - * /), comparisons (< > <= >= == !=), boolean logic (&& ||), ternaries (? :), and string/array/object literals. $varName anywhere in an expression is substituted with that variable's current value before evaluating.