Variable Block

Variable Block

The Variable block stores or updates values inside the game. Scores, affection, item counts, flags — anything that records the player's progress is managed through variables.

Adding a Variable Block

  1. Click the line after which you want the variable to change.
  2. Press [More ▾] on the insert bar and pick Variable from the list.
  3. The new Variable line is inserted right after the selected line. Click it, and the details under the line let you fill in the three fields below.

Key Properties

  • Variable Name (variableName) — The name of the variable this block operates on. Previously used names are offered through autocomplete.
  • Operator (variableOperation) — How the value is applied. Choose one of:
    • = Assign (overwrite)
    • += Add to the current value
    • -= Subtract from the current value
  • Value (variableValue) — The value to use. Numbers, strings, and true/false are all accepted.

Usage Examples

Accumulating a Score

Variable: score += 10      (correct answer)
Variable: score += 0       (wrong — unchanged)

Adjusting Affection

Choice:
  - "Give a flower" → gift_flower
  - "Talk to them" → talk

Chapter: gift_flower
Variable: affection += 5
...

Chapter: talk
Variable: affection += 2
...

Setting a Flag

Variable: met_teacher = true

Referencing Variables in Dialogue

Stored values can be referenced from Dialogue text using the {variable_name} form. The stored value is substituted directly into the line.

Dialogue: "Your current score is {score}."
Dialogue: "{player_name}, your affection is now {affection}."

Usage Tips

  • Naming convention — Names like score or affection_alice stay clear even when you write condition expressions.
  • Initialize up front — At the very beginning of the game (the first chapter at the top of the list), assign initial values (= 0 or = false) to every variable to avoid surprises later.
  • Numbers vs. strings — += / -= only make sense for numeric variables. Strings and booleans usually use = alone.
  • Watch for typos — A typo in a variable name creates a separate variable and can cause branching to behave unexpectedly. Use autocomplete whenever possible.

Next Steps

With variables in hand, let us look at the Condition block, which branches your story based on stored values.