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.
[02:53 am]
Mr.BurnLiquid -- Symmetry
Symmetry shouted: I'll check it out this weekend!
Thanks
[02:47 am]
Symmetry -- I'll check it out this weekend!
[02:40 am]
Mr.BurnLiquid -- Symmetry
Symmetry shouted: Another map maker? Damn we really ARE back
I invite you to try out the map I modified. I don't have the creativity to create maps from scratch, but I do have the know-how to modify existing ones; my project is to tweak community campaigns (specifically those with errors—to make them playable.
[02:27 am]
Symmetry -- Another map maker? Damn we really ARE back
[01:51 am]
Mr.BurnLiquid -- Ultraviolet
Ultraviolet shouted: Mr.BurnLiquid actually yeah though I wasn't really saying it to narc on you. It just caught me off guard because I don't usually see it (because it's against the rules) "The avatar may not be bigger than 150x150 pixels". Kinda silly that it relies on users to be well behaved rather than just limiting the dimensions on uploads :lol:
Now that I wanted to change my avatar, the error image is showing up, haha.
[01:34 am]
Mr.BurnLiquid -- Ultraviolet
Ultraviolet shouted: Mr.BurnLiquid actually yeah though I wasn't really saying it to narc on you. It just caught me off guard because I don't usually see it (because it's against the rules) "The avatar may not be bigger than 150x150 pixels". Kinda silly that it relies on users to be well behaved rather than just limiting the dimensions on uploads :lol:
Mr.BurnLiquid
Mr.BurnLiquid shouted: Ultraviolet Thanks; I'm new to the site and a Spanish speaker. I must have missed the part where it was prohibited—I'll change it now.
I invite you to try out a mission I'm modifying from *StarCraft Reversed*; I'm trying to make it more playable and challenging.
[01:33 am]
Mr.BurnLiquid -- Ultraviolet
Ultraviolet shouted: Mr.BurnLiquid actually yeah though I wasn't really saying it to narc on you. It just caught me off guard because I don't usually see it (because it's against the rules) "The avatar may not be bigger than 150x150 pixels". Kinda silly that it relies on users to be well behaved rather than just limiting the dimensions on uploads :lol:
Thanks; I'm new to the site and a Spanish speaker. I must have missed the part where it was prohibited—I'll change it now.
[01:31 am]
Ultraviolet -- Mr.BurnLiquid
Mr.BurnLiquid shouted: Ultraviolet Is it forbidden to have a large avatar?
actually yeah though I wasn't really saying it to narc on you. It just caught me off guard because I don't usually see it (because it's against the rules) "The avatar may not be bigger than 150x150 pixels". Kinda silly that it relies on users to be well behaved rather than just limiting the dimensions on uploads :lol:
[12:20 am]
Mr.BurnLiquid -- Ultraviolet
Ultraviolet shouted: https://staredit.net/profile/133367/ dude's avatar is massive
Is it forbidden to have a large avatar?
[12:04 am]
Ultraviolet -- https://staredit.net/profile/133367/ dude's avatar is massive
Please log in to shout.


Members Online: UndeadStar, Ultraviolet