HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Truly wierd trigger problem.

12-11-2008, 11:47 AM#1
Kino
Trigger:
Unit Group - Add (Last replaced unit) to Bone_WellAmounts[1]
Unit Group - Add (Last replaced unit) to Bone_WellAmounts[2]

Ok basically Bone_WellAmounts is a unit group array.
The problem is that adding units to this unit group does not work for Array index 2 however it does work for array 1.

Is there any reason why this is so?
12-11-2008, 01:06 PM#2
Monstah
Really trivial question: what size is your array? Sometimes we forget such simple things.

Also, remember that arrays declared in JASS start from index 0, global array variables start in index 1 (I might be wrong). So if it's a size-2 JASS array, it has indexes 0,1; if it is a global of same size, it has indexes 1,2.

Or am I saying bullshit? ^^;

Other than that, can't find a reason.
12-11-2008, 02:18 PM#3
Aeroblyctos
Btw, it's "weird", not "wierd". I really wonder why everyone writes the word like that. :D
12-11-2008, 03:25 PM#4
Kino
Hah ok it seems your right, I did set the array size to less than 2 so i guess that means problem solved.
12-12-2008, 08:04 AM#5
Gorman
try it and see!

But yeah, it should be fixed.
12-12-2008, 09:44 AM#6
ShadowWolf
Quote:
Originally Posted by Monstah
Really trivial question: what size is your array? Sometimes we forget such simple things.

Also, remember that arrays declared in JASS start from index 0, global array variables start in index 1 (I might be wrong). So if it's a size-2 JASS array, it has indexes 0,1; if it is a global of same size, it has indexes 1,2.

Or am I saying bullshit? ^^;

Other than that, can't find a reason.
Triggers work elements in arrays starting at index 1, because the majority of people that have no programming background would not understand that they have to start with 0 =/

And yes, always make sure that the array is large enough to handle the any index arguments you try to use with them.
12-12-2008, 05:10 PM#7
Monstah
So I wasn't saying bullshit? :D

I thought the reason would be that. Just notice when I said "Other than that, can't find a reason", I meant a reason for his code not to work, not for the 0 or 1 index ^_^