Set variable

Assigns an expression result to a variable. The runtime flags every node that depends on the variable so its Visible when expression re-evaluates on the next evaluation phase. For the cross-cutting Condition and Timing properties shared by every event, see Event types.

The Set Variable event composer, expanded in the Node inspector.

Fields

Variable

The variable to write. Pick it from the editor’s variable picker.

The variable must already exist in the project; create it from the Variables data view if it doesn’t yet. The new value is coerced to the variable’s declared type (bool / decimal / int / string).

Value (expression)

An expression that produces the new value. May reference other variables, functions, and operators. Evaluated when the event fires.

Common patterns:

  • Literal: 5, true, "unlocked"
  • Increment: var_score + 1
  • Clamped: Clamp(var_count, 0, 10)
  • Conditional: If(var_helped, 2, -1)

See Expression operators and Expression functions for the full vocabulary.

Use cases

Incrementing a running counter. Pick the counter variable from the Variable dropdown and write var_count + 1 in Value (expression). Every time the event fires the counter advances by a single point. The runtime re-evaluates every node that depends on the counter automatically.

Resetting a one-shot status flag. Pick the flag variable in Variable and write the literal false in Value (expression) to clear the flag once the situation that set it has resolved. The runtime coerces the literal directly into the variable’s declared type.

Adjusting a bounded score with a conditional delta. Pick the score variable in Variable and write Clamp(var_score + If(var_helped, 2, -1), -10, 10) in Value (expression). One event both computes the conditional delta and keeps the result inside [-10, 10].

See also

Docs last synced: 2026-07-08
Screenshot viewer