# [Solved]Difference between non-array variables and array variables.

Status
Not open for further replies.

#### BETA

Level 5
As the title implies, what's the difference between a variable without an array and a variable with an array?

Without arrays:
• Without Arrays
• Events
• Conditions
• Actions
• Set CasterLoc = (Position of Triggering unit)
• Set TargetLoc = (Target point of ability being cast)

With arrays:
• With Arrays
• Events
• Conditions
• Actions
• Set PointLoc[1] = (Position of Triggering unit)
• Set PointLoc[2] = (Target point of ability being cast)

#### FUJI

Level 20
Basically the same thing, IMO It will create; PointLoc1 and PointLoc2. It is like your just assigning them using an integer. However arrays have it's own limitation.

Last edited:

#### BETA

Level 5
What do you mean by limitations?

#### KILLCIDE

Level 37
Imagine non-arrays as backpacks that can only fit one item where as arrays are backpacks that can fit a lot items (8192 to be exact). Of course these items are limited to the variable type you set (ex: unit).

#### BETA

Level 5
So basically you can put an infinite amount of non-array variables in a single map?

#### KILLCIDE

Level 37
Not infinite amount. All the variables you create are initialized on map init. Too many of these variables will make it easier for you to reach OP limit (aka operation limit). I believe the number is like 30000. At this point, the thread will crash.

This is why it is always advised to leave array sizes at 1.

#### BETA

Level 5
I have another question... Does using an array variable in a trigger will affect another trigger with the same variable?

Example:
• Ability 1
• Events
• Unit - A unit starts the effect of an ability
• Conditions
• (Ability being cast) equal to Ability 1
• Actions
• Set Caster[1] = (Triggering unit)
• Unit - Pause Caster[1]

Another ability
• Ability 2
• Events
• Unit - A unit starts the effect of an ability
• Conditions
• (Ability being cast) equal to Ability 2
• Actions
• Set Caster[1] = (Triggering unit)
• Unit - Pause Caster[1]

Last edited:

#### KILLCIDE

Level 37
Only if its the same exact index. For example, you store Caster[1] in Ability 1, but then overwrite Caster[1] in Ability 2. If you didn't want to overwrite it, you would change the index. In this case, any number OTHER than 1 or not less than 0 wouldn't overwrite it (0, 2, 996).

All variables you create from the variable editor are global variables, meaning that all functions / triggers have access to them.

Level 5
Thank you!

#### FUJI

Level 20
Both of the triggers you've shown will not cause conflict to the variables because it's event is instant and it will overwritten it's variables unless you've decided to use timers or waits to change their references dynamically.

The array size limit is greater than 8191 to be exactly what KILLCIDE already mentioned; meaning:
• set Caster[8193] = TriggeringUnit
Will not work.

Last edited:

#### KILLCIDE

Level 37
^ Yeah sorry I misunderstood your question. As long you don't use any periodic loops or triggers with wait timers that need to reference Caster[1], you will be fine.

#### BETA

Level 5
So basically non-array variables are better since it works perfectly in periodic loops and wait timers?

Well my thoughts(at least for me) is that array variables makes creating triggers faster, especially in removing leaks, where I have to type a lot if I'm using non-array variables.

#### FUJI

Level 20
^ Nope, as I've said earlier; if the references of the variables whether it is array or non-array changes dynamically it may cause referencing problems especially when two or more triggered event runs at the same time or a moment.

Edit: You are free to choose if it is array or non-array as long you didn't hit the array limit.

#### BETA

Level 5
Oh that's good news.

Btw, what do you mean by changes dynamically? Can you give me an example?

#### FUJI

Level 20
Im on mobile but here's the illustration on waits;
Trigger One
• Event - Unit starts the effect of an ability
• Condition - Ability being cast equal to CustomAbility123
• Actions
• set caster = (Triggering Unit )
• Wait 2.00 seconds
• set caster = (Triggering Unit )
• Wait 2.00 seconds
• set caster = (Triggering Unit )
• Wait 2.00 seconds
Trigger Two
• Event - Unit starts the effect of an ability
• Condition - Ability being cast equal to CustomAbility123456
• Actions
• set caster = (Triggering Unit )
• Wait 3.00 seconds
• set caster = (Triggering Unit )
• Wait 2.00 seconds
• set caster = (Triggering Unit )
• Wait 2.00 seconds
• set caster = No Unit // in case
• Wait 1.00 seconds
• set caster = (Triggering Unit )
^ Just an example
If the two trigger's event fires at the same time and conditions meet then it will cause trouble or problem on caster variable references, it is the same with arrayed variables. You may need MUI methods for saving the correct references.

#### BETA

Level 5
Blaaaarggghhh seeing that many waits made me cringe

Status
Not open for further replies.

Replies
4
Views
1K
Replies
3
Views
711
Replies
4
Views
547
Replies
2
Views
2K
Replies
2
Views
640