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
887
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.
  • Varine Varine:
    I ordered like five blocks for 15 dollars. They're just little aluminum blocks with holes drilled into them
  • Varine Varine:
    They are pretty much disposable. I have shitty nozzles though, and I don't think these were designed for how hot I've run them
  • Varine Varine:
    I tried to extract it but the thing is pretty stuck. Idk what else I can use this for
  • Varine Varine:
    I'll throw it into my scrap stuff box, I'm sure can be used for something
  • Varine Varine:
    I have spare parts for like, everything BUT that block lol. Oh well, I'll print this shit next week I guess. Hopefully it fits
  • Varine Varine:
    I see that, despite your insistence to the contrary, we are becoming a recipe website
  • Varine Varine:
    Which is unique I guess.
  • The Helper The Helper:
    Actually I was just playing with having some kind of mention of the food forum and recipes on the main page to test and see if it would engage some of those people to post something. It is just weird to get so much traffic and no engagement
  • The Helper The Helper:
    So what it really is me trying to implement some kind of better site navigation not change the whole theme of the site
  • Varine Varine:
    How can you tell the difference between real traffic and indexing or AI generation bots?
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such
  • Varine Varine:
    That's mostly what I've been looking at
  • Varine Varine:
    I don't think I'm dealing with quite the same pressures though, at the very least its a significantly smaller system. For the time being I'm just going to put together a quick scrubby box though and hope it works good enough to not make my house toxic
  • Varine Varine:
    I mean I don't use this enough to pose any significant danger I don't think, but I would still rather not be throwing styrene all over the air

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top