Custom Variables
From Shoot Em Up Kit
Introduction
A custom variable is a way of giving a name to a number, some text, or a Boolean value (true or false) and referencing it from within the game. Some custom variables could include Gold, which is a number specifying how much gold you have; or Experience Points; or Character Name; or anything you can think of that could be referenced in the game to deepen the experience.
Items within the Shoot ‘Em Up Kit have Properties which are frequently used in Shoot ‘Em Up games, properties such as Score, Lives, Health, etc. Custom Variables can expand this list to store information specific to your game.
To create a custom variable click the Custom Variable icon in the Define window.
A list of all the custom variables will be shown. You can modify an existing variable or choose the Create New option.
You can select a name for the variable. It is good to make this descriptive so that it is clear what it refers to. You can also choose the type of variable – whether it is a number, a string of text or a Boolean value. You can also choose a default value and for numeric types you can also set minimum and maximum values.
Modifying Values
Many items that can be placed into levels (including Players, NPCs, Triggers and Timers) support Actions. In the Action tab you can set or modify a variable.
Click on the User Variable property and select which variable you want to adjust. You can then use the Data Action property to specify whether you’d like to set a new value for the variable; or whether you’d like to Add, Subtract, Multiply or Divide the variable’s value.
Reacting to Custom Variables
Any item which supports Actions can respond to variables being greater than, less than or equal to a value. These can be selected in the Event property on the Action tab.
In the example below the Player is comparing the new variable we created to the value 5. If My New Variable equals 5 then it will trigger all the events specified for this Action event (Upgrading, Changing AI State, Activating other Map Items, etc).