Understanding Variables

Variables are like containers that store information in your story. They help you keep track of things like choices made, items collected, or character relationships. When combined with the conditional blocks we learned about earlier, variables become powerful tools for creating dynamic, responsive stories.

Creating Variables

To create a variable:

  1. Click the "New Variable" button at the bottom of the variables section
  2. Enter a name for your variable
  3. (Optional) Add a description to help you remember the variable's purpose

Let's create some variables for a simple adventure story:

Try it out!

Using Variables in Your Story

Variables are "inline" blocks, which means you can use them right within your text. Here's how to display a variable's value:

Try it out!

Setting Variable Values

Variables start empty (undefined) until you give them a value. Use the setter block to change a variable's value:

Try it out!

Putting It All Together

Let's create a more complex scene using our variables.

Note that the following example is intentionally a little more complicated to showcase what is possible with variables and conditional blocks. Most of the time, you will want to rely on the story diagram to handle most of the branching narratives.

Try it out!

Try it out!

Try it out!

Important Things to Remember

  1. Variables are Global: All variables can be accessed from anywhere in your story.

  2. Setting Values: Variables can store:

    • Numbers (like 100 or -5)
    • True/False values (true or false)
    • Text
    • Results of expressions (like playerGold - 50 or friendshipLevel + 1)
  3. Checking Values: Variables can be:

    • Displayed directly in text using inline variable blocks
    • Used in conditions (if blocks)
    • Used in expressions with operators