What does the "array size" matter for?

hi_im_bob

......and you are?
Reaction score
44
Setting the Array size to 1 will only allow you to put in one value for the variable. Setting it to 7 will allow you to use 7 different values in a variable
 

duderock101

Check out my 2 Player Co-op RPG!
Reaction score
71
say you wanted to create two quest with one quest varible. You would put on the array 2. Then you'd do this

Code:
Quest - Create quest with title and description
Set Varible - Quest [1]
Quest - Create quest with title and description
Set Varible - Quest [2]


Plz plus rep if this helped
 

thevoden

New Member
Reaction score
5
I still don't get it.

I can set the variable array size to 1 and still be able to set the array number into different ones.

Whats stopping me from setting the questvariable to the array size of 1 in the trigger section and then doing the following trigger:

set variable - quest [ 1 ]
set variable - quest [ 2 ]
set variable - quest [ 3 ]

???
 

Psiblade94122

In need of sleep
Reaction score
138
from what ive experienced from useing variables....

if its one or over one, then the variable has an array

if its 0 then its not an array

thats all there is to it
 

thevoden

New Member
Reaction score
5
Can you explain that? Is there a difference to setting the variable array size of "setitems" to 3 than it is to setting it to 1?

so lets say I do set the following variables in the triggers:

set setitems [1] = claws
set setitems [2] = mask of death
set setitems [3] = potion

Would it matter if the array size was 1 or 3? If it doesn't then what is the difference between setting it to an array size? Why is there even an option to do this?
 

Flare

Stops copies me!
Reaction score
662
ìf the array size is 1, you arent able to do the above 3 set variables, since the array value of the second two exceed the array size of the variable.

if the array size is 3, itll work fine

so, to sum it up

Would it matter if the array size was 1 or 3? If it doesn't then what is the difference between setting it to an array size? Why is there even an option to do this?

yes, it does matter.
 

Psiblade94122

In need of sleep
Reaction score
138
tell you the truth, other then setting it to one, i have no clue.....

best you ask blizzard about this XD

but.. in my mind....

i see the ability to but arrays in a variable as a booline (meaning its either true or false) if its 1 or >1 then it is true (meaning you can use the array with as many arrays as you want) if its 0 then its false (meaning that you cannot use arrays for that variable)

for evedence that i can use and unlimited ammount of arrays after setting it to one....

for almost all my maps, the player controlled unit is set under "hero[1]" meaning that its under the unit variable hero, and under an array size of one

i have 10 players

if it exeeded the array size by 9, then none of my maps would work, but they do work

if you want to challange me, go look for my maps in the members projects (not the invaders one because that is currently singleplayer only) and you will see what i mean.... or do you want me to upload a open version here so you can check
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
888
Has anyone actually tested this?
I just did with an Integer variable.

I set the size to 1, then stored 1, 2, and 3 in the indexes 1, 2, and 3.
Then I looped through them to display them on the screen.
It displayed all three.

So, if this does matter with something, I don't know what it is as it doesn't seem to affect the ability to store things in it.

I would guess that the size refers to the initial memory allocated to the variable, and that if you use more elements than you originally specified, it automatically assigns more memory.
 

SerraAvenger

Cuz I can
Reaction score
234
If you mean the Array size in the Variable Editor: The size only indicates which fields are initialised with the starting value you entered in the other field. Although you only set it to 5, you can use the array on 8192 fields later.

Like:
ThisIsAnExample Integer Array (4) 5

Would mean that the fields 1 - 4 are set to 5 in the map initialisation.
However, later in the code, you can still refer to
ThisIsAnExample[ 213 ]

The maximum value you can ever use is 8192, whatever you enter in the variable editor.
Hope that helped, Davey Jones.
 

13est

New Member
Reaction score
5
I think I can make a good example.

As for my TD I got a variable that is called Level. It is an unit type variable with array 1-60.

When the map is started I have to set all arrays (I don't think there is another way)

Ex.
Set variable "Level [1]" = Footman
Set variable "Level [2]" = Ghoul

And after that the spawn trigger can be made.

Ex.

Spawn 1 unit of unit type "Level [x]"
(and after that)
Set variable "Level [x]" = "Level [x]" + 1

(I'm not sure, but I think you have to set Level = 1 first of all. )

It might look complicated, but these are not real triggers but just about how they look, and in the end it will look like this.

Spawn 1 unit of type "Level [1]" (footman)
Set variable "Level [1]" = "Level [1] + 1 (and that would be Level [2], so the next time the trigger runs it will be a ghoul)

Hope it helped a little bit.
 

thevoden

New Member
Reaction score
5
I know that.

I completely understand you. But in the TRIGGER editor itself, when you first create a variable, it gives you an ARRAY size. You can do all of the above setting the array to "1" and still be able to use what you were saying.
 

Knight7770

Hippopotomonstrosesquiped aliophobia
Reaction score
187
In that case, it's probably just there to make things easier to read while in the variable editor.
 

Slapshot136

Divide et impera
Reaction score
471
the array size is for what array #'s the "default" value is, isnt it? so like if you have an array of 3, then 0-3 have the default set and 4-8000 something dont have it set.. isnt it?
 
S

Slate.Master

Guest
I would guess that the size refers to the initial memory allocated to the variable, and that if you use more elements than you originally specified, it automatically assigns more memory.

Answered it all, IMO. It means that if you have a variable with array value = [1] but want to use variableX[2]/[3]/[4]/etc... the game auto creates the new arrays.
 

foodflare

You can change this now in User CP.
Reaction score
32
not always some arrays dont work that way, such as the timer window array.
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,494
> not always, some arrays dont work that way

All arrays work that way.

The "difference" being that some variable types need to be created before you can use them.


As an example, if you create an array of unit groups of size 1,
the action "unit group - add unit" will work with groups 0 and 1 as soon as the maps starts,
but that same action on group 2 will fail, simply because there's no group there to put the unit into.
And, no, the game will not magically invent new content...

However, there's no problem to use:
Set array[2] = Units in <region> (or some other pick action) on that same size 1 array.
 

SerraAvenger

Cuz I can
Reaction score
234
And after that the spawn trigger can be made.

Ex.

Spawn 1 unit of unit type "Level [x]"
(and after that)
Set variable "Level [x]" = "Level [x]" + 1

Spawn 1 unit of type "Level [1]" (footman)
Set variable "Level [1]" = "Level [1] + 1 (and that would be Level [2], so the next time the trigger runs it will be a ghoul)

Hope it helped a little bit.

Actually this would not work most probably, although this is offtopic.
IF you want to make it work, use:
A gobal integer variable ( non array ) with the starting value 1, called LevelNumber
and in the trigger you would do this:
Code:
Spawn 1 unit of unit type "Level [ LevelNumber ]"
Set variable "LevelNumber" = "LevelNumber" + 1

What you actually did was not advance in the array ( like from Level[ 1 ] to Level[ 2 ] ) , but you increased the value hold b the field in the array by 1.
This means if it would've been Level[ 1 ] = 11212331, afterwards it would be:
Level[ 1 ] = 11212331 + 1 = 11212332
Hope that helped you too, Davey
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top