• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

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