So I recently added a pulldown to my ui and figured I could simply use it by looping through my array and adding all the elements, then I could read the selected index and use that to access my array... WRONG!
Here are some things you should know about pulldowns:
Unlike arrays they are not zero indexed, the first index is 1
The first item you add to the list will appear first in the list, any item added after that will appear in reverse order in the remaining list.... wtf?!?
So what this means is that if you have a zero indexed array with an element in the 0th element to create a working list you need to,
Add element zero to the list.
Loop through the remaining elements in your array in reverse order and add them to the list box.
Yeah I noticed this too... I don't get why it's like this and it confused me for a little while until I realized what it was doing. It's probably just a bug and it should be fixed once the retail version comes out... at least I hope so. I guess once you realize how it works it isn't too bad. It's just confusing at first.
Yeah I suppose, just wanted to give people a heads up on this. Only annoying part is that if they don't fix this at release and then suddenly decide to fix it in some random patch a lot of maps will probably break.
Unlike arrays they are not zero indexed, the first index is 1
As far as I know, the first index of an array is either 0 or 1 depending on what the entries are for that array. I have plenty of arrays that begin at 1.
Yeah I suppose, just wanted to give people a heads up on this. Only annoying part is that if they don't fix this at release and then suddenly decide to fix it in some random patch a lot of maps will probably break.
Yeah I was thinking about that too. They probably wouldn't fix it too long after release for that reason. Then again it isn't very hard to fix that in your map, but it's still a pain.
As far as I know, the first index of an array is either 0 or 1 depending on what the entries are for that array. I have plenty of arrays that begin at 1.
Even if you begin entering your data at entry number 1 in the array SC2 will allocate memory for the 0th element of the array. You could start entering data from element 100 and up but SC2 would still allocate memory for element 0-99. Which is why it is referred to as a zero index array.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
So I recently added a pulldown to my ui and figured I could simply use it by looping through my array and adding all the elements, then I could read the selected index and use that to access my array... WRONG!
Here are some things you should know about pulldowns:
So what this means is that if you have a zero indexed array with an element in the 0th element to create a working list you need to,
Here is my code that I use for my map,
@Beider: Go
Yeah I noticed this too... I don't get why it's like this and it confused me for a little while until I realized what it was doing. It's probably just a bug and it should be fixed once the retail version comes out... at least I hope so. I guess once you realize how it works it isn't too bad. It's just confusing at first.
@apasseroni0014: Go
Yeah I suppose, just wanted to give people a heads up on this. Only annoying part is that if they don't fix this at release and then suddenly decide to fix it in some random patch a lot of maps will probably break.
As far as I know, the first index of an array is either 0 or 1 depending on what the entries are for that array. I have plenty of arrays that begin at 1.
Yeah I was thinking about that too. They probably wouldn't fix it too long after release for that reason. Then again it isn't very hard to fix that in your map, but it's still a pain.
Even if you begin entering your data at entry number 1 in the array SC2 will allocate memory for the 0th element of the array. You could start entering data from element 100 and up but SC2 would still allocate memory for element 0-99. Which is why it is referred to as a zero index array.