Variables


General

Variables can be used to store data inside a graph or the whole Flowgraph project.
You can view them in the “Variables” window:

The main sections are:

  • Current Graph:
    Variables are only accessible in the currently viewed graph.
  • Manager Variables:
    Variables are accessible in the entire Flowgraph project.

Variables can have the same types as pins, with some exceptions like “Table” and “Flow”.
You can use your variables in your flowgraph by using the “Get” and “Set” nodes. You can create them in different ways:

  • Pressing the Getter or Setter buttons in the “Variables” window.

  • Using any other possible method for node creation:


Things to look out for


Frame Delay

One thing to keep in mind when working with variables is that they are only actually set at the end of the frame. This means if you set a variable at the start of a graph and try to retrieve that new value at a later point, it will still hold the previous value of the variable, if there was one.
The “Variables” example project showcases how to handle this kind of problem.
If there are variables or general values that you want to pass on between states, you can use transition variables. You can read more about them on the Elements page.


Multiple Setters

Another thing to be mindful about when working with variables is, setting a variable multiple times per frame.
Because Flowgraph allows for multiple active states and general branching, there is no way to ensure the order in which the values of the variable will be set. This can lead to unwanted behaviour and is why we do not recommend using variables in this way.

To give you more control over how your variable will behave in this kind of situation, you can choose from different options for “Merging” in the “Variables” window.
There are different options for the behaviour, depending on the variable’s type.

Type
Option
Result
Type
Generic
Option
readOnly
Result
The variable cannot receive a new value from a Setter node only constant values through the Variables window.
Type
Option
first
Result
The first value that was set will be the new value.
Type
Option
last
Result
The last value that was set will be the new value.
Type
Number
Option
min
Result
The lowest of the values will be the new value.
Type
Option
max
Result
The highest of the values will be the new value.
Type
Option
average
Result
The average of the values will be the new value.
Type
Option
sum
Result
The sum of all values will be the new value.
Type
Bool
Option
or
Result
The logical or of all set values will be the new value.
Type
Option
and
Result
The logical and of all set values will be the new value.
Type
String
Option
concat
Result
All set values will be concated directly.
Type
Option
concatComma
Result
All set values will be concated with a comma as the seperator.
Type
Option
concatSpace
Result
All set values will be concated with a space as the seperator.
Type
Option
concatNewline
Result
All the set values will be concated with a newline as the seperator.
Last modified: June 22, 2021

Any further questions?

Join our discord
Our documentation is currently incomplete and undergoing active development. If you have any questions or feedback, please visit this forum thread.