User Tools

Site Tools


variables

Variables / Switches / Collections / Tables

Variables, Switches, Collections and Tables are all important in 001 Game Creator, and the development of your games, when it comes to storing and manipulating information/data. Their initial state can be set in the Variables/Switches/Collections/Tables window, but more useful is that they can be manipulated with scripting events in your game.


Global Variables

Variables in general can hold any numeric/text values which can be used in your game. In the case of numbers, they can be used to store the amount of enemies the player has killed, how many steps a player has taken, etc. Or in the case of text, they can be used to store the name of a pet the player has named.

You can define variables that are accessible through any script (called Global Variables) in the Variables/Switches/Collections/Tables window. If you would like to define a variable only used in a specific script (called a Local Variable), use the “Local Variables” button in the Script Editor, as discussed below.

The “Variable Operation” event is used to assign values to your Global Variables. You can then use these variables in any event that asks you to specify a variable as a parameter (eg: “Actor Loop”, “Field Loop”, etc.). You can also reference these variables in Use Value scripting by selecting the variable from the “Global Variables” section of the Use Value dialog. The “Comparison Branch” and “Multi-Comparison Branch” events are used to compare an expression to a value(s). You can use these events to create branching paths within your scripts based on the values they're holding.


Switches

Switches on the other hand can only hold one of two values at any one time: ON or OFF. Unless indicated through the Variables/Switches/Collections/Tables window, a Switch’s default value will be OFF at the start of the game, but can be turned ON and OFF by using the “Switch Operation” event. These can be used for simple binary situations that only need a yes/no answer to progress, such as if part of the story has been completed, a particular NPC has been interacted with or perhaps an enemy has been killed.

You may only define global Switches (which are accessible through any script). If it is more desirable to have a local Switch, Local Variables can do the job just fine of representing an ON/OFF state by using the numbers 0 and 1.

The “Switch Operation” event is used to change a Switch's state from ON to OFF. You can also specify to “Toggle” the Switch instead, which will turn it ON if it's currently OFF and vice versa. The “Switch Branch” event is used to check the state of a Switch. If it's ON, it'll take the left path and if it's OFF it will take the right path instead. You can also reference Switches in Use Value scripting by selecting the Switch from the “Switches” section of the Use Value dialog.


Collections

Collections are a way of holding a sequential series of text or numbers. These can be used for storing a lot of information that would otherwise require a large amount of separate Global Variables such as storing previous player game moves, diary/log entries, or lap times for a racing game.

Collections and their initial set of values are defined through the Variables/Switches/Collections/Tables window.

The “Add to Collection” event is used to add new values to a Collection. The “Clear Collection” event will remove all values a Collection holds, whilst the “Remove from Collection” event will remove a specific value inside the Collection. You can also reference Collections in Use Value scripting by selecting the “nth Element in Collection” Use Value in the Use Value dialog.


Tables

Tables are very much like Collections, except that they can store a 2- or 3-dimensional grid of text or numbers. Each cell containing information is defined by 3 co-ordinates X, Y and Z (similar to how Maps and Interfaces work). In fact, their usefulness often comes from mapping out the layout in relation to a Map, where each cell in the Table could represent a particular tile in the Map. Though they can be merely used to store various metadata about an object or player, by using columns and cells appropriately.

The “Resize Table” event is used to increase/decrease the number of available cells to store data in. These cells can then be filled using the “Edit Element of Table” event by specifying the X, Y and Z coordinates of the cell. The “Clear Table” event will remove all data from within a Table, whilst leaving its cells intact, while the “Reset Table” event will remove all data and all cells from a Table. You can also reference Tables in Use Value scripting by selecting the “Element in Table” Use Value in the Use Value dialog.


Local Variables

These Variables are created within a script and can only be used within that script. Local Variables will not be accessible outside of the script they were created in. Their main use is to store data temporarily in one script, such as holding a generated random number for use in other events, or counting how many times the player has made the same dialogue choice.

Local Variables can be made persistent by ticking the box next to their name. Persistent Local Variables remember any data stored in them after a script has ended, meaning their information can be reused later if the script is executed a second time, much like Global Variables.

The “Variable Operation” event is used to assign values to your Local Variables. You can then use these variables in any event that asks you to specify a variable as a parameter (eg: “Actor Loop”, “Field Loop”, etc.). You can also reference these variables in Use Value scripting by selecting the variable from the “Local Variables” section of the Use Value dialog.


Map/Interface Variables

These are created in Map/Interface property windows and can be used on the Map or Interface in which they were created but these can also be called throughout the entire game through the “Map Variable” and “Interface Variable” Use Values.

The “Map Variable Operation” and “Interface Variable Operation” events are used to assign values to your Map/Interface Variables. You can also reference these variables in Use Value scripting by selecting the “Map Variable” and “Interface Variable” Use Values in the Use Value dialog.


Actor Variables

These are created in the Actor property window and can be used on the Map in which they were created but these can also be called throughout the entire game through the “Actor Variable” Use Values, with the exception of Actor Variables that have been created within an Actor Template. These can only be accessed through the Actor Template in which they were created.

The “Actor Variable Operation” event is used to assign values to your Actor Variables. You can also reference these variables in Use Value scripting by selecting the “Actor Variable” Use Value in the Use Value dialog.

variables.txt · Last modified: 2017/01/19 12:30 by Lee