Docs OmiScript

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.

$var — save-slot variable. Stored in the player’s save and restored whenever they load it. Reset on a fresh playthrough. Use it for almost everything story-related: branching flags, relationship scores, counters, the choices themselves.
$$var — persistent variable. Lives in the player’s global state, separate from save slots. Never rolled back — even a new game leaves it intact. Use it for meta-game state: “has this player ever reached Ending B”, global achievements, cross-playthrough unlocks.

Assignment

Every assignment starts with the variable, then an operator and a value.

SyntaxOperatorEffect
$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)
Numeric operators (-=, *=, /=) 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.

conditions.omi
? 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.

interpolation.omi
$player_name = "Alex"

mira: "Hey, $player_name. Good to see you."

Gated options

Hide a choice option unless a condition is met.

gated.omi
? "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.omi
## 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