Tutorial - Variables – Ylands
If you want to script you will need to get your hands dirty with variables, numbers, strings and similar elements. In this scene we demonstrate some of the basic operations.
The Red Trigger Zone
We have created a variable called Number of Entries in this Trigger Zone script. Whenever the player enters it, the variable is incremented and its value written to the chat window. All number operations can be found under Numbers section.
The Blue Trigger Zone
Here we write out who has just entered the Trigger Zone. The parameter Trigger entity value is set to whoever has entered the zone so we can easily have it printed out. Notice that we actually print two strings merged together - the first part is made of the entity (when the script finds we are trying to use it as a string it automatically converts it into one) and a text string.
The Green Trigger Zone
As you can see in the script, we can easily detect if a variable has been set to some value by simply checking, if it is true.
Note:
There are two types of variables (and arrays)
Local variable, which exist only within a scope of certain custom instruction
Member variable (or simply “variable”) which exist in the scope of given entity’s script and can be accessed from any event or custom instruction existing in this script. If this variable is located within a Global Storage Game Logic, it can be accessed from any other script in the game.