Hi! I'm Antikore and I want to show you something awesome for your games.
I named these things as "Dynamic Variables"
A dynamic variable is a variable that uses bracketings for the variable name. This is awesome to set different variables without needing to have multiple times the same code.
A good example is making an item that when collected sets a variable specific for the current area we are, with this we can make super mario 64-like star system.
//The star nº1 from the current area is collected, so is set to true
game var stars[area]_n1 = true
If we are on the area with id 25, the variable will set the variable stars25_n1 to true. We can check an specific variable by just replacing the bracketing with the possible returned value. For example, if we want to check for the star nº1 from the area 18, just change [area] to 18
if game var stars18_n1 = true
//What to execute if we have the star nº1 from the area 18
I have used this on my dungeon game with the character system.
The character select has a variable that refers to which character is selected by the player
var chara = 1 //Set the character selected to 1
Each time you use your arrow keys, you add or remove to this variable, and the character values change to the saved for that new character.
How?
//Example:
if game var ch[var chara]_level = 1
{
var level = 1
var price = 100
}
Hope you learned something new from this tutorial. Thanks for reading and see ya next time!