15. Give the puzzle a memory
Variables remember what has happened. A door needs a door_open flag. A collectible needs a key_taken flag. A score is a number. Good variables let the graph ask a clear question instead of trying to infer the entire puzzle from what happens to be visible.
| ID | Type | Starting value | Purpose |
|---|---|---|---|
| key_taken | Boolean | false | Prevents a second pickup reward. |
| door_open | Boolean | false | Records the completed door puzzle. |
| score | Number | 0 | Tracks the points awarded. |
| pulse_count | Number | 0 | Counts a demonstration loop. |
| loop_index | Number | 0 | Receives the For Loop index. |
| last_target | String | empty text | Stores an event entity ID. |
| busy | Boolean | false | Prevents overlapping starts when required. |
1. Open Variable Designer and add the variables your lesson needs.
2. Give each a stable ID, a readable name and the appropriate type.
3. Set the starting value, apply and save.
4. Return to the graph and choose the variable from the relevant dropdown.
5. Restart the preview to test those authored starting values.
Use a Boolean for a yes/no state. A text value containing the word false is not the Boolean false. A missing variable is also not the same as a correctly initialized false flag.
Declare important puzzle state in Variable Designer even though several runtime nodes can create destinations by name. Declared variables are easier to discover, inspect and maintain.
