Simple Variable Question

Cfw_Master

New Member
Reaction score
1
I've been reading many guides on triggers but I couldn't figure out what variables with a [1] or [2] were.

When I created my own variables, I couldn't create them with brackets at all.

Thanks for your help!
 

ZiggyMcjoney

Data editor?! AAAHHHHH!
Reaction score
95
When creating the variable, there is a checkbox "Array". Make sure that is checked :)

You don't need to change the number next to "Array", you can leave it as 1 and still be able to make as many arrays as you want.
 

Dameon

"All the power in the world resides in the eyes"
Reaction score
127
When creating the variable, there is a checkbox "Array". Make sure that is checked :)

You don't need to change the number next to "Array", you can leave it as 1 and still be able to make as many arrays as you want.


To a point you do not need to change the 1, but if you plan to use the array in a loop then you will want to set the array to be larger or it wont work for any array over 1.
 

Dois

New Member
Reaction score
1
umm

why? why dont we need to declare how large the array is in the first place???
 

ZiggyMcjoney

Data editor?! AAAHHHHH!
Reaction score
95
To a point you do not need to change the 1, but if you plan to use the array in a loop then you will want to set the array to be larger or it wont work for any array over 1.

Really? Never noticed that before. o_O
 

Dameon

"All the power in the world resides in the eyes"
Reaction score
127
humans have imaginations, we look at the array and can imagine a larger number then is specifyed in the code, so we refrence these larger numbers, now the game AI on the other hand has no imagination, it takes what is written as unchangable fact and wont even try to refrence above any limit placed in front of it, in short the game AI is like a religous fanatic, even if you point out conterdictions to it in the bible (the game data) it wont bodge on what it belives to be true.
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
To a point you do not need to change the 1, but if you plan to use the array in a loop then you will want to set the array to be larger or it wont work for any array over 1.

This has only a little bit of truth to it.

Variables such as Units, Points, Integers, Players, etc. do not need to be initialized, so it does not matter what you put for the array default value, and how many array members are set to the default. However, some variable types have to be initialized before they can actually be used, such as Unit Groups, Player Groups, Timers, and a few others.

For Unit Groups and Player Groups:

If you do not initialize these, and try to Add Units/Players to these groups, it will not work. The Group does not yet exist. However, if you create a group for these variables, either by using the "Set Unit_Group = (Units ....)" or by simply initializing it, you can add Units/Players to these groups.

Timers simply have to be initialized, since it's not possible to create a timer in the GUI (without JASS custom script).

@Dameon

Computers are not magical, or anything like that, they are purely logic. :p They do what they are told. If you try to tell the computer to do something illogical (such as adding units to a nonexistent group), it will simply say "I can't do that!" and give an error telling you why it was unable to do what you told it to do.

Warcraft III (this is true for a lot of programs) simply has a lot of fallbacks (programmed into the game), so that even if you tell it to do something impossible (such as create a unit at a non-existent location), it will simply try and do something alternative (such as create the unit at the center of the map, as a default location).

There are a lot of other fallbacks you simply don't notice, such as dividing by 0. Warcraft III would rather crash the thread if it finds one of those, rather than the game. Then, Windows would rather crash the game, than let the game try to calculated X / 0, which prevents a blue screen of death (the computer would run out of memory, since it is an infinite equation that has no real answer).
 

Dameon

"All the power in the world resides in the eyes"
Reaction score
127
If you read my post that is prety much what I said only in way better words then I used. Also I have actualy devided by 0 in triggers a few times with no crashing, it must have to be done in a certain way or maybe I found a loop hole, also if you reread my post I said to a point you wont have the change the 1 for the loop, I never said you absolutly had to set it higher.
 
General chit-chat
Help Users

      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