State

State in StoryBonsai is held in variables: named, typed values you author in the editor’s Data mode and read everywhere the editor accepts an expression. When a variable changes, the runtime re-checks every condition that reads it, so your edits propagate without you having to think about it.

For the full inspector field tour and per-type authoring patterns, see Variables.

The four types

A variable has one of four types, set when you create it.

  • bool: true or false. Use for flags: “the player has the key,” “the alarm is ringing,” “Anne has been introduced.” Default is false.
  • decimal: a number with a fractional part. Use for currency, percentages, continuous physical quantities. Default is zero.
  • int: a whole number. Use for counters, scores, integer measurements like “how many times the player has visited this scene.” Default is zero.
  • string: text. Use for the player’s name, a chosen class, any piece of authored text the rest of the project needs to refer back to. Default is the empty string unless you set one.

(List shows up as a fifth option in the type picker, used for tag-bucket machinery. It isn’t ready for production use yet; treat the four types above as the writer’s vocabulary.)

Why your changes appear instantly

When a variable changes, the editor doesn’t re-test every expression in the project. It re-evaluates only the expressions that actually depend on what changed: Visible when conditions on nodes, Resolved when on scenes, conditions and value expressions on events, captions that interpolate the variable. So if a Set variable event fires, or you edit a default in the data view, the cost is paid only where some expression has something new to look at.

The editor tracks those dependencies for you. You author the variable; the editor figures out which other places need another look the next time the variable’s value changes.

So don’t write expressions to be cheap. Write the expression that says what you actually mean, even if it’s elaborate. The dependency tracking pays the bill.

See also

  • Nodes and Visibility: the rule that decides which nodes show up as choices, which is the most common place a variable gets read.
  • Expressions: how to write the rule that goes inside a Value (expression) or Visible when field.
  • Variables: the entity-shaped view, covering every field on the inspector, per-type authoring patterns, and the Set variable event composer.
  • Error messages: Variables: panel messages about writes to read-only variables and unused declarations.
Docs last synced: 2026-07-08
Screenshot viewer