Why does sc2 make it so hard to properly use arrays? It took me forever to convert my whole map to galaxy script because all natives and libraries return player ids and ask for player ids starting at 1. It seems like a much better idea to make everything start at 0 and make it easier for us and not waste array space. Everywhere I see on the forums are people using arrays as if they start [1], this boggles my mind and I wonder at why blizzard supports them. Not sure where anyone got the idea that arrays start at 1, they never have and probably never will.
It all comes down to making the scripting tools easier to use for beginners.
Humans naturally start counting from 1, which is why Blizzard decided to make most indexes start at 1 (Not all do though.). I personally dislike this as it teaches beginners wrong programming habits and makes it harder to understand for people who already have coding experience.
This is also the reason why GUI arrays are always 1 element bigger than their defined size.
it's funny. in wc3 I started with 1. couple of years and programming knowledge later I start with 0 in sc2 now :P
I think it's good to start at 0. 0 sounds like something that would skip/trigger nothing, which might be required to solve a problem. 1 sounds like something that starts somewhere and does something whether it should or not.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Why does sc2 make it so hard to properly use arrays? It took me forever to convert my whole map to galaxy script because all natives and libraries return player ids and ask for player ids starting at 1. It seems like a much better idea to make everything start at 0 and make it easier for us and not waste array space. Everywhere I see on the forums are people using arrays as if they start [1], this boggles my mind and I wonder at why blizzard supports them. Not sure where anyone got the idea that arrays start at 1, they never have and probably never will.
@penguinwars: Go
Make player 0 a player then o.O
(and get rid of player 15).
"... not waste array space. "
Oh, the inhumanity!
@Charysmatic: Go
I tried that and it wasn't letting me set player 0 as a player. How were you able to accomplish this?
@penguinwars: Go
(and get rid of player 15).
It all comes down to making the scripting tools easier to use for beginners.
Humans naturally start counting from 1, which is why Blizzard decided to make most indexes start at 1 (Not all do though.). I personally dislike this as it teaches beginners wrong programming habits and makes it harder to understand for people who already have coding experience.
This is also the reason why GUI arrays are always 1 element bigger than their defined size.
Player 0 is indeed a player (Neutral).
it's funny. in wc3 I started with 1. couple of years and programming knowledge later I start with 0 in sc2 now :P
I think it's good to start at 0. 0 sounds like something that would skip/trigger nothing, which might be required to solve a problem. 1 sounds like something that starts somewhere and does something whether it should or not.