Staredit Network > Forums > SC2 Assistance > Topic: [SOLVED] Simple Array question
[SOLVED] Simple Array question
This topic is locked. You can no longer write replies here.
Jan 2 2011, 8:07 pm
By: payne  

Jan 2 2011, 8:07 pm payne Post #1

:payne:

I'm just wondering: if I set a variable to have 1 array, will it have only Var[0], or will it have Var[0] and Var[1] ?

Post has been edited 1 time(s), last time on Jan 3 2011, 5:59 pm by payne.



None.

Jan 2 2011, 8:31 pm Roy Post #2

An artist's depiction of an Extended Unit Death

I believe setting the array size in Galaxy includes the index of the array length, which is kind of dumb because it doesn't work like that for any language of which I am aware.

So it would have Var[0] and Var[1].

If you try to set an index out of bounds directly, Galaxy will change it to the last index in the array. For example, if you tried putting Var[2], the editor will recognize it as out of bounds and set it to Var[1] when you hit "Ok."

Having an array of size 1 doesn't make sense, anyway; you would just have a normal variable.




Jan 2 2011, 9:15 pm payne Post #3

:payne:

Quote from Roy
Having an array of size 1 doesn't make sense, anyway; you would just have a normal variable.
Based on what you're saying, array size of 1 gives a variable 2 arrays, and it would thus not be just a normal variable. ;o



None.

Jan 2 2011, 10:20 pm Ahli Post #4

I do stuff and thingies... Try widening and reducing the number of small nooks and crannies to correct the problem.

When you define the array (the variable), you define the length/size (together with data type).

example:
If you define an integer myArrayVariable[1], you will only have myArrayVariable[0] existing.

If you define an integer myArrayVariable[10], you will have myArrayVariable[0, 1, 2, 3, ..., 7, 8, 9] existing.


edit:
this is wrong. next post is the correct answer.

Post has been edited 1 time(s), last time on Jan 2 2011, 11:05 pm by Ahli.




Jan 2 2011, 10:23 pm Roy Post #5

An artist's depiction of an Extended Unit Death

Quote from Ahli
When you define the array (the variable), you define the length/size (together with data type).

example:
If you define an integer myArrayVariable[1], you will only have myArrayVariable[0] existing.

If you define an integer myArrayVariable[10], you will have myArrayVariable[0, 1, 2, 3, ..., 7, 8, 9] existing.
In most languages, this is the case. This is wrong for Galaxy. myArrayVariable[10] ranges from 0 to 10, and the actual array length would be 11.

Quote from payne
Quote from Roy
Having an array of size 1 doesn't make sense, anyway; you would just have a normal variable.
Based on what you're saying, array size of 1 gives a variable 2 arrays, and it would thus not be just a normal variable. ;o
Yeah, I'm saying that if you wanted an array of size 1, you should just make a non-array variable. The smallest array you can have in Galaxy will be of size 2 (index 0 and index 1).




Jan 2 2011, 11:04 pm Ahli Post #6

I do stuff and thingies... Try widening and reducing the number of small nooks and crannies to correct the problem.

Quote from Roy
Quote from Ahli
When you define the array (the variable), you define the length/size (together with data type).

example:
If you define an integer myArrayVariable[1], you will only have myArrayVariable[0] existing.

If you define an integer myArrayVariable[10], you will have myArrayVariable[0, 1, 2, 3, ..., 7, 8, 9] existing.
In most languages, this is the case. This is wrong for Galaxy. myArrayVariable[10] ranges from 0 to 10, and the actual array length would be 11.
My mind just blew up?!
ok, so now I'm stopping to waste space ;D




Jan 3 2011, 3:47 am payne Post #7

:payne:

So if I have 2 arrays for a variable, it'll create Var[0], [1], and [2], thus letting me use [Triggering Player] ?
So this is wrong?



None.

Jan 3 2011, 4:11 pm Roy Post #8

An artist's depiction of an Extended Unit Death

Quote from payne
So if I have 2 arrays for a variable, it'll create Var[0], [1], and [2], thus letting me use [Triggering Player] ?
Two arrays? A multi-dimensional array, you mean? Or an array of size 2? If it's an array of size 2, then yes, it will have Var[0], Var[1] and Var[2]. You can use (Triggering Player) or any other integer function. Of course, you'll have to watch for out-of-bounds exceptions when doing this.

Quote from payne
So this is wrong?
Yes, it is inaccurate. It's making the assumption that Galaxy's arrays work like arrays from other programming languages.




Jan 3 2011, 5:58 pm payne Post #9

:payne:

Ok, thanks.



None.

Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[2026-7-23. : 6:40 am]
Oh_Man -- true
[2026-7-23. : 3:16 am]
RIVE -- Still annoyed there was never a trigger to stop or pause wavs.
[2026-7-23. : 1:40 am]
Oh_Man -- tthen u come to SCBW and it's like - upload WAV, play WAV.... sigh why cant it be that easy
[2026-7-23. : 1:40 am]
Oh_Man -- and no consistent easy to use way to then play the audio either
[2026-7-23. : 1:39 am]
Oh_Man -- where they use third party audioprogram called WWISE which basically makes adding audio extremely difficult
[2026-7-23. : 1:39 am]
Oh_Man -- i appreciate SCBW's ability to just let us upload and play WAVs so much compared to nightmare that is total war warhammer 3
[2026-7-18. : 2:27 am]
Symmetry -- https://staredit.net/topic/18903/ THE REVIEWS ARE HERE! "ok these are pretty good memes" - ssj9Kevin
[2026-7-17. : 2:58 pm]
Ultraviolet -- Symmetry
Symmetry shouted: Man I wish we had this tech back in the day when people played ums lmao
fr fr
[2026-7-17. : 2:39 am]
Symmetry -- Man I wish we had this tech back in the day when people played ums lmao
[2026-7-16. : 6:28 am]
NudeRaider -- EUD actions, specifically. The conditions remained. Today we can even have actions again, but they're all virtualized/whitelisted (not sure on the actual technical implementation) so you can only use them for specific intended purposed, not arbitrary code injections.
Please log in to shout.


Members Online: NudeRaider