• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Variables naming variables

G

Gamma

Guest
I have been working all day on developing a data storage system that is constantly being added to.
Basically I want to create a system that would store the players party/team while being added to,
I tried using methods like this on a loop:

exists[n] = 0{
//create data then loop
PN[n] = PC_Manager.name
PTNL[n] = 20
PLV[n] = PC_Manager.LV
PS[n] = PC_Manager.S
PHP[n] = PC_Manager.HP
PMHP[n] = PC_Manager.MHP
PATK[n] = PC_Manager.ATK
PDEF[n] = PC_Manager.DEF
alarm_set(0,1)
} else {
n += 1
}

but whenever I run this it crashes and says its not in an array, whats going wrong, and/or is there an easier way to do this?
 

Zechevalier

Member
I found this in the user manual, maybe it will help you

array[2] = 0;
array[1] = 0;
array[0] = 0;


Our array now contains three positions (0, 1 and 2) and we have initialized our array to 0. What does that mean? Well, an array has to be initialized before we can use it or GameMaker: Studio will give us an error. Initializing an array just means that we give each position of the array an initial value in preparation for it to be used elsewhere in the object or code. This is important to remember as it means that you have to do a certain amount of planning before using arrays, but it is easy enough to initialize one using a repeat loop like this...
There's more information in the user manual under
Reference > GML Language Overview > arrays
 
Top