• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

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

Status
Not open for further replies.
Level 5
Joined
Aug 7, 2016
Messages
55
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)
 
Level 20
Joined
Aug 13, 2013
Messages
1,696
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:
Level 5
Joined
Aug 7, 2016
Messages
55
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:
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 20
Joined
Aug 13, 2013
Messages
1,696
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:
Level 5
Joined
Aug 7, 2016
Messages
55
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.
 
Level 20
Joined
Aug 13, 2013
Messages
1,696
^ 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.
 
Level 20
Joined
Aug 13, 2013
Messages
1,696
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.
 
Level 5
Joined
Aug 7, 2016
Messages
55
Blaaaarggghhh seeing that many waits made me cringe

201602_1801_gigbb_sm.jpg
 
Status
Not open for further replies.
Top