Skip to main content
How to Use Variables in StoryFlow Editor - Featured image
Tutorials March 4, 2026 • 12 min read

How to Use Variables in StoryFlow Editor

So you've got a conversation working in StoryFlow Editor. Characters talk, the player picks options, the story moves on. Cool. But right now every player sees the same thing every time. The NPC doesn't know you already helped them. They don't care that you have the key. Nothing changes based on what the player did before.

Variables fix that. They let your story remember things.

In this tutorial I'll go over how variables work in StoryFlow Editor - what types there are, how to create them, and how to actually use them in your scripts. I'll also share some setups that I find myself using over and over again.

What Are Variables in StoryFlow Editor?

A variable is just a named value that your story can read and change. You give it a name like hasKey or playerHealth, and it holds some data - a number, some text, true/false, etc.

You know when you play an RPG and a guard says "I heard you helped the blacksmith" even though you did that quest hours ago? That's a variable doing its job. When you finished the quest, a flag was set to "true". Now the guard's dialogue checks that flag and reacts to it.

In StoryFlow Editor, variables live in the Variables Panel on the left sidebar. You create them there and drag them onto the canvas when you need them.

Variable Types

There are several types to choose from. Each type has its own color in the editor so they're easy to tell apart.

Boolean

True or false. That's it. You'll use these all the time for tracking whether something happened. Did the player meet this NPC? Did they pick up the key? Is the quest done?

I name mine with prefixes like has, is, or can: hasKey, isQuestActive, canEnterCastle. Makes it way easier to understand what each one does when you have a lot of them.

Integer

Whole numbers: 0, 1, 42, -5. Good for anything you count - health, gold, how many times the player visited somewhere, relationship scores.

You get all the basic math (add, subtract, multiply, divide) and comparisons (greater than, less than, equal). There's also a Random node that picks a number between two values - useful for dice rolls or random events.

Float

Decimal numbers like 3.14 or 0.5. You probably won't need these as often as integers, but they're there for when you need more precision - damage multipliers, percentages, things like that. Same math operations as integers, just with decimals.

String

Text. Player's name, current location, a custom message. You can compare strings, search inside them with Contains, join them with Concatenate, or change case with ToUpper/ToLower.

Common example: save the player's name in a string and use it in dialogue. "Welcome back, Elena" feels much better than "Welcome back, adventurer."

Enum

Enums are great. An enum can only be one of a specific set of values that you define yourself. For example, you create a questStatus enum with values: NotStarted, InProgress, Completed, Failed.

Instead of checking questState == 2 and trying to remember what 2 even means, you check questStatus == Completed. Much clearer, and you can't accidentally set it to a value that makes no sense.

The Switch On Enum node is really useful here - it gives you a separate output for each value, so you can branch your story cleanly without stacking up a bunch of checks.

Asset Variables: Image, Character, and Audio

These don't store numbers or text - they point to files in your project:

  • Image - reference an image file for swapping backgrounds or portraits
  • Character - reference a character file (.sfc), useful for changing who speaks
  • Audio - reference an audio file for dynamic music or sound effects

You might not need these right away, but they're nice to have as your project gets bigger.

Arrays

Any type except enum can be turned into an array - an ordered list of values. An integer array could be an inventory of item IDs. A string array could track visited locations. A character array could be your party members.

You get the usual operations: Add, Remove, Get Element, Contains, Length, and more. The For Each Loop node goes through every item in the list one by one, which is handy for things like checking if any party member has a certain trait.

How to Create a Variable

It's simple:

  1. Open a script file
  2. Find the Variables Panel on the left
  3. Click the + button
  4. Pick a name, type, and default value
  5. Choose Local or Global scope (more on this below)

That's it. The variable appears in the panel and you can drag it onto the canvas.

Local vs. Global Variables

Every variable is either local or global. This matters more than you'd think.

Local variables only exist in the script file where you created them. They reset to defaults every time the script runs. Use them for temporary stuff - tracking choices within one conversation, loop counters, things that don't need to stick around.

Global variables can be read and changed from any script in the project. They're saved in a separate global-variables.json file and don't reset between scripts. You'll see a little globe icon next to them. Use these for player health, gold, quest flags, or anything that multiple scripts need access to.

I'd say start with local. If you later realize another script needs access, just select the variable and check the "Is Global?" checkbox in the edit panel on the right. It's easy to go from local to global, but harder to go back.

Get and Set Nodes

There are two ways to work with variables on the canvas:

Get nodes read the value. Drag a variable from the panel, pick "Get", and you have a node that outputs the current value. You can also right-click the canvas and find them in the Variables section.

Set nodes change the value. They have four connections:

  • Execution Input (top left) - when to set it
  • Value Input (bottom left) - what to set it to
  • Execution Output (top right) - what to do next
  • Value Output (bottom right) - passes the value along for chaining

Conditional Dialogue Options with Variables

This is where it gets fun. Every dialogue option in StoryFlow Editor has a condition input. Hook up a boolean to it, and that option only appears when the value is true.

Say you have a locked door with three dialogue options, and one of them is "Unlock the door." Connect a Get Boolean for hasKey to that option's condition. Players without the key don't even see the option. Players with the key do, and it feels natural.

You can also combine conditions with And, Or, and Not nodes. Maybe opening the door needs the key AND the guard's permission. Two Get nodes, one And node, connect it to the condition. Done.

Logic and Math Nodes

Quick overview of what's available:

Boolean Logic

  • And - both must be true
  • Or - at least one must be true
  • Not - flips true to false and back
  • Equal - are they the same?

Number Comparisons (Integer & Float)

  • >, >=, <, <=, ==

Arithmetic

  • +, -, ×, ÷
  • Random - pick a number between two values

Worth noting: integer division rounds down, and dividing by zero gives you 0 instead of an error.

The Branch Node

You'll use this one a lot. Give it a boolean and it splits your flow into a True path and a False path.

For example: use a Greater Than node to check if goldAmount > 100, plug it into a Branch, and show different dialogue based on whether the player has enough money.

Type Conversions

Sometimes you need to convert between types. It works how you'd expect:

  • Boolean to Integer: true = 1, false = 0
  • Boolean to Float: true = 1.0, false = 0.0
  • Integer to Float: just adds a decimal. Float to Integer rounds to nearest (3.6 becomes 4, 3.4 becomes 3)
  • Number to String: 42 becomes "42" and back
  • Enum to String: converts an enum value to its name. You can also go from String or Int to Enum

If you try to convert something like "hello" to a number, you get 0. Nothing breaks.

Character Variables

Characters in StoryFlow Editor (.sfc files) can have their own variables. Every character comes with Name and Image built in, and you can add whatever else you need - affection, mood, health, flags.

You work with them through two nodes: Get Character Variable and Set Character Variable. This lets you do things like check a companion's loyalty before a big decision, or slowly raise an NPC's trust over time.

Passing Variables Between Scripts

If you use a Run Script node to run another script, you can send variables in and get results back. Toggle Input on a variable to accept a value from outside, or Output to send it back when the script is done.

This is useful for reusable scripts. For example, make a "shop" script that takes goldAmount as input and returns the updated amount. Write it once, call it from anywhere.

Keep in mind that local variables reset every time a script runs. If data needs to survive between scripts, make it global or pass it through Input/Output.

Common Variable Patterns for Game Narratives

Here are some variable setups I use often:

Quest Tracking

  • questAccepted (boolean) - did the player take the quest?
  • questProgress (integer) - what step are they on?
  • questCompleted (boolean) - is it done?

Or better yet, use an enum: questStatus with values NotStarted, InProgress, Completed, Failed. Cleaner and harder to mess up.

Inventory

  • Simple: hasKey, hasSword, hasPotion (booleans)
  • With quantities: potionCount, goldAmount (integers)
  • Advanced: inventory (integer array of item IDs)

Start with booleans. You can always switch to arrays later, and booleans are way easier to debug.

Relationships

  • metCharacter (boolean) - have they met?
  • relationshipLevel (integer, -10 to +10) - how do they feel about the player?
  • isAlly / isEnemy (booleans)

A tip here: use integers for relationships instead of booleans. "Likes you / doesn't like you" feels flat. A scale from -10 to +10 gives you room for things like grudging respect or cautious friendship. Much more interesting.

Player Stats

  • health (integer, 0-100)
  • mana (integer, 0-100)
  • level (integer, 1-99)
  • playerName (string)

Tips

A few things worth keeping in mind:

  • Name things well. hasCompletedBlacksmithQuest takes longer to type than flag1, but in a few months you won't remember what flag1 was for.
  • Start local. It's tempting to make everything global just in case, but then you end up with dozens of globals and no idea what's changing them.
  • Be consistent with naming. camelCase, snake_case, whatever - just pick one and stick with it.
  • Delete unused variables. If you remove a feature, remove its variables too.
  • Use enums instead of numbers for states. questStatus == Completed is always clearer than questState == 3.

What's Next

That covers everything you need to get started with variables. Start small - a few booleans and an integer or two. You can always add more types as your story grows. The important thing is that your story can now actually react to what the player does.

For the full technical reference, check out the Variables documentation and Node Types reference.


Want to try it? Get StoryFlow Editor on Steam and start making your stories remember things.

Enjoyed this post?

Subscribe to get notified about new articles and updates.