What Is A Variable?
A Variable is simply somewhere to store numbers, values or strings so that they can be called upon later. Think of variables as items you can put in and take out of boxes (hence SGB’s references).
I’m going to be as comprehensive as possible with this series. However, you can skim through the parts you already know and, as the series progresses, skip to the parts you’d like to know more about.
There are several types of variables in Smile Game Builder:
- Basic Variables
- Advanced Variables
- Conditional Variables
- Trigger Variables
- String Variables
- Auto-Synched Variables
Basic Variables are used for simple operations to directly affect the targeted Variable No. with specific values.
You can assign a fixed value to the variable or you can use math operators – add, subtract, multiply and divide – with this value.
Besides the usual math operators, you can also add a random number in variable box between 1 and whatever number is placed in Value up to a maximum 999,999. This does exactly as it states and adds the random number to the variable; it doesn’t create a random number (that’s in the Advanced Variables section).
The basic Variable Box is primarily used for setting up quick, simple variables and manipulating them with the operators.
ALL values are fixed and can’t be directly influenced by other variables. It can kind of be done, but I’ll cover that in a later tutorial.
In Advanced Variable Box Op., you can do much more with variables (as you can see in Fig. 3 below).
These are values specific to various parts of the game and they can be stored and manipulated in the same way as basic variables. And we’ll go through each of them over the course of this tutorial.
This is where you set the variable you want to use. The maximum allowed variables in a single game is 999, although you can repurpose them or reuse other established variables on different maps if you’re not using them elsewhere on the same map.
Variable Box is used and referenced the same as in the Basic Variables. There is another option in the dropdown, Number Displayed in Variable Box, but we won’t worry about that just yet.
This section is for selecting the type of operator to use with the variable. In addition to the usual math operators, you (obviously) set the variable’s value with Assign.
There’s one other operator, Substitute Divided Remainder, which divides the variable’s value by the assigned number and uses the remainder as the value. I covered modulo operations already in a previous tutorial, but I’ll expand on this later as well.
This is what you want to store in variables (or the items you want to put into the box). As you can see in Fig. 3, there are quite a number of options. And, while this isn’t as comprehensive as it could be, it still contains a sufficient amount to achieve some advanced tasks.
You can use advanced variables to set "fixed" variables instead of the basic Variable Box. The two are the same and do the same thing.
Personally, I like using the basic Variable Box if my variables are simple values not reliant on anything except for fundamental calculations. And then I use the Advanced Variable Box for more complex operations. I’ll use this method throughout the series.
It may be just a matter of preference when setting up the basics for more advanced stuff later, so choose whichever one you prefer.
In the Next Parts
Over the course of the tutorial, I’ll examine each one in more detail, including explanations on how and where they can be used, along with examples as necessary.
I covered Advanced Variables in my video series in Tutorial #11 (as well as some later videos). Much of the content will be expanded upon throughout this series.
Although I won’t go into as much detail (except perhaps in a future article), I’ll utilize the event’s Conditions in conjunction with variables. And I’ll share some of the techniques I’ve learned in the process, such as how to properly set up a cut scene using only variables.