Creator · Visual Scripting
Visual Scripting Variables
Variables are typed values owned by a script. They are useful for counters, cooldowns, state flags, and cached values that should survive from one handler dispatch to the next.
engine v1.0.234Copy for LLM
Authoring
- Create variables in the Variables panel.
- Use Get Variable nodes to read values.
- Use Set Variable nodes to update mutable values.
- Use immutable variables for constants that should not be changed by the graph.
Each variable has a name, type, mutability flag, and default value.
Runtime Behavior
Runtime stores variable values outside the QuickJS VM, keyed by the room, entity, script, and variable. A value persists across handler dispatches for the same entity and script. Values reset when the room closes, the entity despawns, or the variable schema changes.
Body-only script edits preserve compatible values. Adding, removing, renaming, or changing a variable type resets that script's variable state for the entity.
SDK Access
Generated scripts use the same backing store through:
const current = ctx.script.variables.score.get();
ctx.script.variables.score.set(current + 1);
Advanced scripts can target another script on an entity when that script exists in the runtime catalog:
ctx.entity("enemy_1")?.script("health")?.variables.hp.set(0);