Global Variables

Global variables are a great tool to control the flow of your game. Let's assume a specific event in the game shall only happen after the player has spoken to a certain character. This could be accomplished with a simple boolean variable that is set to "true" after the conversation and a condition checking the state of this variable right in front of the event.
The new system folder "global variables" offers a view to keep track of all the global variables in your project.



The global variables list comes with the following columns:
  • Variable set 1: The variable's group (or namespace).
  • Name 2: The variable's name. As global variables must be useable within code, the name has the same constraints as for example the technical name of objects (no spaces or special characters).
  • Description 3: Enter a short text to describe the usage of a global variable.
  • Type 4: A global variable can be of type Boolean, Integer, or String.
  • Default value 5: The variable's default value.
  • Delete variable 6: The "x"-button in the last column deletes the variable.

Variable Sets

Global variables are always created inside a variable set, which allows grouping of belonging variables. Think of variable sets as folders for variables or if you have a programming background you could compare them to namespaces. You can create a new variable set by clicking on this button 7 in the toolbar:



The created variable set will automatically be selected in the Navigator. This reduces the view on global variables to the ones inside that group.



A variable set itself has a name and a description text. Because variable sets are used in scripts, the name has some constraints (no spaces or special characters). To address a global variable within scripts it's necessary to put the containing variable set in front: VariableSet.Variable.
Variables inside the same set cannot have the same name to avoid ambiguity.

Creating Global Variables

Global variables must always be created inside a variable set. As long as no variable set exists, it's not possible to create a new global variable. To create a new variable set, go to the global variables system folder and click on the according button in the toolbar (see above). The created variable set will automatically be selected. Click on the "X"-button 8 in the toolbar to create new variables inside this set.




It's also possible to create new variables directly inside the global variables system folder. Just select a variable set from the dropdown in the toolbar 9. Clicking on the "create new variable"-button will now create the variable inside the chosen set.

Renaming Variables

When renaming variables usually all occurrences of this variable in the flow or in object templates are updated accordingly, so that all scripts should stay intact. In some cases the connection between a variable and its usage in scripts is only temporary. In this case a rename will trigger the following dialog:



Clicking on "rename and update" will search for all scripts where the variable is in use and will update all of these occurrences. "Rename without update" will skip this step. Please be aware that this can lead to errors in your current scripts.

Moving Variables between Sets

If you want to move a variable from one variable set to another, you can do so in the global variables list. Just select another variable set from the dropdown in the variable set column 10.