Variables & conditionals
Track choices, scores and flags, then branch on them. Variables are declared in Studio → Variables, then read and written anywhere in your script.
Session vs persistent
Two kinds of state, two dollar signs. Choose based on how long the value should survive.
Assignment
Every assignment starts with the variable, then an operator and a value.
| Syntax | Operator | Effect |
|---|---|---|
$score = 0 | = | Set to a literal value or expression |
$score += 10 | += | Add (numbers only) |
$score -= 5 | -= | Subtract (numbers only) |
$score *= 2 | *= | Multiply (numbers only) |
$score /= 2 | /= | Divide (numbers only) |
-=, *=, /=) only make sense on numbers — the linter warns if you use them on a string variable, or assign a value that doesn’t match the declared type. Conditions
Branch your story with ? if / ? elif / ? else. Only the first matching branch runs.
? if $route == "friendship": sarah: "I'm glad we talked." ? elif $route == "tense": sarah: "I hope you change your mind." ? else: "They stood in silence."
Comparisons: ==!=><>=<=. Logical: andornot. Combine them freely, e.g. ? if $score >= 10 and $met_sarah:
Interpolation
Drop a variable straight into any string — the engine substitutes its value at runtime.
$player_name = "Alex" mira: "Hey, $player_name. Good to see you."
Gated options
Hide a choice option unless a condition is met.
? "What do you say?" - "I believe you" [$trust >= 1] player: "I believe you." - "I don't trust you" player: "I don't trust you."
The condition goes after the option label in square brackets. Options that fail the condition simply don’t appear.
A worked example
Scoring, persistent flags, interpolation and chained conditionals all together:
## The Score @bg classroom // Variables are declared in Studio → Variables before use. // $var — session variable, saved with save slots, reset on a new playthrough. // $$var — persistent variable, survives all playthroughs — for global flags, meta-unlocks. $score = 0 $player_name = "Alex" teacher: "Welcome, class. Let's begin." ? "First question: what is 2 + 2?" - "Four" teacher: "Correct!" // Arithmetic operators: += -= *= /= $score += 10 -> Next Question - "Five" teacher: "...close enough." $score += 3 -> Next Question - "I don't know" teacher: "At least you're honest." -> Next Question ## Next Question ? "Capital of France?" - "Paris" $score += 10 -> Results - "London" $score -= 5 -> Results ## Results // Chain conditions with ? if / ? elif / ? else ? if $score >= 15: teacher: "Impressive result." // Persistent flag — this player has scored high at least once, ever $$high_scorer = true ? elif $score >= 5: teacher: "Not bad." ? else: teacher: "We'll keep practicing." @end
Storyomi Creator Docs
Back to Storyomi