Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
Imagine normal variable as a building with 1 room only. This is nothing special right? Just one room, you may put something inside but that's about it.
An array would be one building that has many rooms. The same logic applies as with the 1 room-only building -> you can put some things inside each room.
But how do you find out in which room you have what? How do you differentiate those rooms? Well, you simply number them.
One room will have number 1, another room may have number 2, and so on.
The difference between building with 1 room and building with many rooms is obviously the amount of rooms each has. Of course you can create many buildings with 1 room, but really, why do it complicated when you can create 1 building with many rooms?
Basically that is the logic behind non-array and array variables.
You can save only 1 thing inside non-array variable; you can save more things inside array variable by giving it different indexes (numbers)
The advantage of using arrays is that you can easily access the data with simple code (mainly using loops), while using non-arrays forces you to manually add each variable you use.
Look at this bit of pseudo-code:
Set x1 = X of unit1
Set y1 = Y of unit1
Set x2 = X of unit2
Set y2 = Y of unit2
Set x3 = X of unit3
Set y3 = Y of unit3
Set x4 = X of unit4
Set y4 = Y of unit4
Basically you save X and Y coordinates of unit1-unit4
If you were to do this via arrays, then it would be like this:
For each integer variable loop_var from 1 to 4 do (Actions)
Loop
Set x[loop_var] = X of unit[loop_var]
Set y[loop_var] = Y of unit[loop_var]
This trigger is faster, easier to change and you won't get lost in it and it does exactly the same as the previous trigger.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.