theres no way that works in sc2... post your real code.
if it worked in wc3 its cuase it had dynamic arrays, that got bigger as you added to them. Most arrays are not like this. (I never used wc3, so Im not sure how it worked)
I dunno how most people use them, but I typically use arrays so I can use "for loop integer A" triggers. Makes it so you can have one trigger that applies for all players in the game at the same time. Extremely helpful to avoid having to redo all your triggers.
i edited my initial post and took out all the extra fluff and left the important actions there
hmm so arrays are different than in warcraft 3?
so for my example above, in starcraft 2 i would have to set weapon variable to a item variable array of size 4? (cause in warcraft 3 a size 1 array would suffice for this trigger)
Arrays are indeed different in sc2. You must set them to the size you wish to use or you'll get an underflow/overflow error. Also, arrays start indexing at 0 not 1.
i have used arrays before in warcraft 3, but i have always just set the array to a default size 1, and there have been no problems
what is the purpose of setting array size to greater than 1?
for example this is a trigger i have used with no problems with array size=1
rnd = integer variable,
weapon = item variable array of size 1
set weapon[1] = gun,
weapon[2] = bazooka,
weapon[3] = machinegun,
weapon[4] = rocket launcher
action:
set rnd = random integer from 1 to 4
create 1 weapon[rnd] for player 1
array size=1 works for this, so when is array size greater than 1 used?
theres no way that works in sc2... post your real code.
if it worked in wc3 its cuase it had dynamic arrays, that got bigger as you added to them. Most arrays are not like this. (I never used wc3, so Im not sure how it worked)
As mentioned, arrays have a pre-defined size and exceeding that bounds will cause an overflow.
I dunno how most people use them, but I typically use arrays so I can use "for loop integer A" triggers. Makes it so you can have one trigger that applies for all players in the game at the same time. Extremely helpful to avoid having to redo all your triggers.
i edited my initial post and took out all the extra fluff and left the important actions there
hmm so arrays are different than in warcraft 3?
so for my example above, in starcraft 2 i would have to set weapon variable to a item variable array of size 4? (cause in warcraft 3 a size 1 array would suffice for this trigger)
rnd = integer variable,
weapon = item variable array of size 4?
set weapon[1] = gun,
weapon[2] = bazooka,
weapon[3] = machinegun,
weapon[4] = rocket launcher
action:
set rnd = random integer from 1 to 4
create 1 weapon[rnd] for player 1
@HatsuneMikuMegurine:
Arrays are indeed different in sc2. You must set them to the size you wish to use or you'll get an underflow/overflow error. Also, arrays start indexing at 0 not 1.
ok arrays start indexing at 0
so if i have 4 weapons then array size = 4
and weapon[0]...weapon[3] ?
or can i use weapon[1]...weapon[4] ? and skip using 0?
cause in another thread some posters said:
_____
Hint: In an array of length 10, the first element has an index of 0 and the last element has an index of 9.
Reply: If the array is defined as "size 10" in the GUI, it actually gets a size of 11, though
_____
So can i use weapon[1]...weapon[4] ? and skip using 0 to make things match correctly?
@HatsuneMikuMegurine: Go
You can start at 0. You can start at 15 if you'd prefer.