• 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!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Variable Array Size

Status
Not open for further replies.
Most of the time, when I use a variable array, size 1 is enough for the variable.
But when I used a Unit Group array, It didn't work until I increased the Array Size.
Which kinds of variable do I have to increase the sizes?

It really depends. By default, all the other slots will return "null" if you try to refer to them (for strings: "", booleans: false, integers: 0, reals: 0)

You just have to know how you're going to use it. In your case, you have to define a size because you need to use the groups as is. You are adding units to the groups. However, if you create groups on your own (e.g. "Units within 500 of some point"), then you don't need to have that sizing (you're going to end up creating the groups yourself). The "size" part is just telling the editor to initialize N slots of the array (starting at 0) with some default object.

In the case of groups, it is an empty group. So if you need an empty group at that slot, feel free to modify the variable size. If you are going to make one yourself, then just keep the size as 1 or 0.

There isn't really a cookie-cutter solution on when to use it and when not to use it. For example, with an effect array--you'll end up creating the effects yourself so you don't need to increase the size field. However, if you are using groups where you just need to add units, then you need to set the size (otherwise you'll add units to a null group [does nothing]).
 
I had to increase the size of the unit group array for it to work. why was that?

Because defining an array size only initializes the variable up to the index you put, it doesn't actually change the arrays size.

It would be best to handle the group creation yourself but you can still define the "size" if you'd like.
 
Status
Not open for further replies.
Top