• 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.

How to change the array's number

Status
Not open for further replies.
Level 45
Joined
Feb 27, 2007
Messages
5,578
There are two possible things you could mean:
  1. The 'size' of an array is set to 1 and cannot be increased.
    • This doesn't matter. All indices of an array up to 16383 are able to be written to and read from despite the array size value.
    • Array sizing only affects how many indices of the the array are given the default value on map init (#'s 0 through (SIZE-1) are initialized).
    • Erroneously using a large size for non-primitive variable types may be considered a memory leak if those indices are never used or are overwritten before being properly cleaned.
  2. Some types of variables cannot have default values assigned to them when they are made into arrays.
    • Or you are confused that you can't assign different default values to different indices, which you can never do because that's not what "default value" means.
    • Mostly these are handle types.
You should also be aware that after converting a variable into an array, it will be necessary to go back through every trigger that uses that old non-array version and manually change every single instance of the variable to properly use some array index. GUI will not do this for you, and it will appear to be correct until you attempt to launch the map at which point it will crash when such at trigger is executed in-game or cause some sort of compiler error on-save.
 
Level 24
Joined
Feb 27, 2019
Messages
833
Its best to change variable size within the variable editor. Doing it in the trigger editor will disable all uses of the variables within triggers and also doesnt work intuitively since one has to reselect the variable type after changing size, and even after doing that, selecting another variable directly after will mess that one up too.
 
Last edited:
Status
Not open for further replies.
Top