Variables: Array Sizes, what are their functions?

tom_mai78101

The Helper Connoisseur / Ex-MineCraft Host
Staff member
Reaction score
1,732
In theory, variables with arrays in WE would look like this:

Variable[x]: Size 1.
Variable[x][y]: Size 2
Variable[x][y][z]: Size 3
etc.

But from sources within WE Help Zone, some people say that array sizes can only be 1, and will never go past 1. Some people would say that sizes being how large would affect the map size. Some, with experiences, like Acehart, would say that sizes can change everything to a variable.

I know about size 1 arrays, but what else are the sizes 2 and up are for? A grid? Or a plane? Or it's just an unconventional bug Blizzard developers missed out on?

As a Japanese man would say, "It would be an honor to understand the mysteries around us..." :rolleyes: Maybe...

What are they exactly for? Their functions? Not how to do it, or what is an array, or something tutorials would mention about.
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
All arrays can hold precisely the same maximum number of values. 8192. And it starts at 0. And you do not want to use the final index 8191.

The size determines how many values, from 0 to that size, limits included, are initialized with the default value.

The default value, for example on player groups, is an empty group.
Do you expect "Player group - Add <player> to Group[10]" to work if that group has not been created yet?

Map size? Nonsense.

8000 as size? Your "init" triggers will reach the operations limit and never make it to the end...
 

tom_mai78101

The Helper Connoisseur / Ex-MineCraft Host
Staff member
Reaction score
1,732
So, using sizes is like (using loops for (how large (the number of size) is) for that (default value))?
 

MurderMode

Giving new meaning to co-op... slowly
Reaction score
154
array sizes have nothing to do with creating a grid or plane, it's just how many seperate peices of data you can tie into 1 variable.

A variable with no array holds a single amount of data, whether it be an integer or a unit or whatever.

A variable with an array size of 1 can hold two lots of data, one in the array '0' and one in the array '1'.

An array with the size of 99 stores one hundred peices of info, starting at 0 and going up to 99.

It's basically just so you can use one single variable for a specific number of tasks. A good example being when you want to use a unit variable for a hero on each team. If there are 12 heroes all up, the minimum size array you would use is 11 (however i would make it 12 so that it's easier to set player 1-12 to it's specific number, and I just wouldn't set 0 to anything).

I don't know where you got ur idea that array sizes can only be 1, I have seen another thread you have posted that you are using (integer A) with the integer ranging from 1-6 and 7-12 ..... that's an array size of 12 right there in your own trigger...

oh and I don't know what the 'variable [x][y][z]' is supposed to mean.... notice that in a variable array the part in the square brackets says [index] when u need to set it.

here is a dictionary meaning for index - 2. a sequential arrangement of material, esp. in alphabetical or numerical order.

what I am trying to say is that a variable is like a book... and the array is the pages. On page 1 you draw a druid, on page 2 you draw a shaman and on page 3 you draw a warlock.

book_variable[1] = druid
book_variable[2] = shaman
book_variable[3] = warlock

...it's that simple.
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
> So, using sizes is like (using loops for (how large (the number of size) is) for that (default value))?

If you create, for example, an array of type integer, with size 5, and a default value of 3, the editor will add something like this to your map:

For each Integer A from 0 to 5, do
- Set myArray[Integer A] = 3


You can still use myArray[42] if you want... however, don't try to use it before you actually set it to something...
 

tom_mai78101

The Helper Connoisseur / Ex-MineCraft Host
Staff member
Reaction score
1,732
Oh...I wish I could give you +rep, but you're full.

Thanks for your answer.
 

MurderMode

Giving new meaning to co-op... slowly
Reaction score
154
Did I just write that for the fun of it or did you actually read it and understand what an array is :S

or did I completely misunderstand the question because to me it looks like you don't get the whole point of an array, and you might be confusing yourself in it's use if you don't grasp the basics first....
 

tom_mai78101

The Helper Connoisseur / Ex-MineCraft Host
Staff member
Reaction score
1,732
I can't comprehend your post, just below this "An array with the size of 99 stores one hundred peices of info, starting at 0 and going up to 99." line. Acehart said it like it was in a loop.

So, I took the Simplier English. Sorry if it bothers you. And since you're not as full as Acehart, for your efforts on that post up there, +rep.
 

Alphabet

New Member
Reaction score
12
or did I completely misunderstand the question because to me it looks like you don't get the whole point of an array
Or maybe you're the one not getting it? :) A variable with array 1 can store more than 2 values as you claimed (and as I've read many times, so not blaming you or anything). As Acehart said: "The (array) size determines how many values, from 0 to that size, limits included, are initialized with the default value". It doesn't determine the amount of slots that can be used.
If you don't believe it otherwise, you could try making an integer with array size 1 and try out these actions:
Code:
Actions
    For each (Integer A) from 1 to 100, do (Actions)
        Loop - Actions
            Set i[(Integer A)] = (Integer A)
            Game - Display to (All players) the text: (String(i[(Integer A)]))
            Wait 0.10 seconds
Works perfectly.
 

tom_mai78101

The Helper Connoisseur / Ex-MineCraft Host
Staff member
Reaction score
1,732
If I were to make a variable sized 2, what would it look like in the triggers? Sized 3?

I'm comparing, if you wanted to know the reason why I ask these questions.
 

tom_mai78101

The Helper Connoisseur / Ex-MineCraft Host
Staff member
Reaction score
1,732
So, size 1 variable is: Variable[x], where x stands for a number.
Size 2 and 3 doesn't show anything else in the triggers?
And that's it, no other kinds?
 

darkRae

Ueki Fan (Ueki is watching you)
Reaction score
173
x stands for the index.
Size 1 and 2 or 3 just show how many Default Values have been set for that variable.

What other kind?
 

MurderMode

Giving new meaning to co-op... slowly
Reaction score
154
alphabet what you typed was an array size of 100 tho... setting the value of the index to integer A from 1-100 means it's looping for each value.

With integer A being from 1-100, your index value is actually going to loop like this -

Integer A = every number from 1-100

i[integer A] = i[1], i[2], i[3], i[4], i[5], i[6]... all the way up to i[100].

that is a variable with and array size of 101 (if counting an i[0]), not 1 array.

It's probably why tom was getting confused with what an array is (ie. assuming it becomes a grid whenit increases in number).... because people think that integer A counts as an array size of 1... when it's actually whatever u set integer A to be. I wasn't responding with a post to say setting the array size is or isn't necessary, I was just trying to clarify what the numbers mean in an array.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top