Documentation on working with variables

The start

We will use the project made in the previous documentation: First program


All variables are divided into 3 groups:

  • Global variables
  • Local variables
  • Object variables

Creating variables

Global variables can be created in functions and in config.cfg

Locals variables can be created in functions and exists only in this function

Object variables can be created in objects (.obj and .cobj in scene), variables unique for every object

Using global and local variables

Using the get variable and set variable nodes, you can manage local and global variables

In this example, we get the local variable var1 and output its contents to the console, we also get the variable var2, add 5 to it and save it

Using object variables

To use object variables we need nodes get object variable and set object variable, they differ from the previous ones in that they have one more parameter - object ID

To get the object ID, we need the get object ID by name node, which accepts the object name when adding it to the scene

To create an object variable, select the object on the stage and set the variables in the window on the right

They will also be copied from the object that was used to add to the scene, if you have previously added them to this object