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.
[06:57 am]
maxar39174 -- Outdoor gym and fitness equipment manufacturer and suppliers https://mountwoodco.com/outdoorgym-equipment-manufacturer-in-uttar-pradesh.php
[06:57 am]
maxar39174 -- Outdoor gym and fitness equipment manufacturer and suppliers https://mountwoodco.com/outdoorgym-equipment-manufacturer-in-uttar-pradesh.php
[06:57 am]
maxar39174 -- Outdoor gym and fitness equipment manufacturer and suppliers https://mountwoodco.com/outdoorgym-equipment-manufacturer-in-uttar-pradesh.php
[06:56 am]
maxar39174 -- Outdoor gym and fitness equipment manufacturer and suppliers https://mountwoodco.com/outdoorgym-equipment-manufacturer-in-uttar-pradesh.php
[06:56 am]
maxar39174 -- Outdoor gym and fitness equipment manufacturer and suppliers https://mountwoodco.com/outdoorgym-equipment-manufacturer-in-uttar-pradesh.php
[06:56 am]
maxar39174 -- Outdoor gym and fitness equipment manufacturer and suppliers https://mountwoodco.com/outdoorgym-equipment-manufacturer-in-uttar-pradesh.php
[06:56 am]
maxar39174 -- Outdoor gym and fitness equipment manufacturer and suppliers https://mountwoodco.com/outdoorgym-equipment-manufacturer-in-uttar-pradesh.php
[05:02 am]
Oh_Man -- whereas just "press X to get 50 health back" is pretty mindless
[05:02 am]
Oh_Man -- because it adds anotherr level of player decision-making where u dont wanna walk too far away from the medic or u lose healing value
[05:01 am]
Oh_Man -- initially I thought it was weird why is he still using the basic pre-EUD medic healing system, but it's actually genius
Please log in to shout.


Members Online: Roy