Jass and variables. A question.

BlightWarden

New Member
Reaction score
6
Can I use the same variable for multipul actions, even if they are all happening at once or will I need a new variable for each action?

Situation:
I have multipul regions where units will spawn, I am spawning them in Temp_point_A. Can Temp_Point_A be used by more than one trigger at the same time? If I kill a creep in region A and you kill a creep in region B and both spawn at the same time, will it work if I only use a single variable? Do we share?

Trigger exsamples. (These units spawn in different regions using the same point variable. Both spawn at the same time? Will it work?

Trigger:
  • Creep Spawner A
    • Events
    • Conditions
    • Actions
      • Set Temp_point_A = (Center of (Playable map area))
      • Unit - Create 1 Footman for Player 1 (Red) at Temp_point_A facing Default building facing degrees
      • Custom script: call RemoveLocation (udg_Temp_Point_A)



Trigger:
  • Creep Spawner B
    • Events
    • Conditions
    • Actions
      • Set Temp_point_A = (Center of (Playable map area))
      • Unit - Create 1 Knight for Player 2 (Blue) at Temp_point_A facing Default building facing degrees
      • Custom script: call RemoveLocation (udg_Temp_Point_A)

I just want to know if I can use a single variable to clean all the spawn leaks or if I will need Temp_Point A,B,C and so on.

Thanks for any and all replies.

[edit] Can't slip nothing past you guys! Fixed triggers. ;)
 

Exide

I am amazingly focused right now!
Reaction score
448
Your example triggers leak.
Yes, you can use the same variable infinitive times - as long as you don't overwrite it. (If you want to change it, you need to clean it first.)
 

Hellohihi

New Member
Reaction score
42
Yes global variables generally works in mui triggers.
As long as there are no waits inbetween, and the actions are instant.

The 2 triggers that you posted can work simultaneously if fired together.
 

BlightWarden

New Member
Reaction score
6
Yes global variables generally works in mui triggers.
As long as there are no waits inbetween, and the actions are instant.

The 2 triggers that you posted can work simultaneously if fired together.

What if one triggers after the other? Will that mess anything up? If one triggers a few seconds after the other will that have a negative effect?
 

Hellohihi

New Member
Reaction score
42
I should rephrase that:

The 2 triggers that you posted can work simultaneously if fired together.

into

The 2 triggers that you posted can work simultaneously if fired together, or after, or before, as long as the trigger is instant and there are no waits inbetween.
 

BlightWarden

New Member
Reaction score
6
I should rephrase that:



into

Ok, so to be 100% sure I'm not screwing up, will these two triggers work?

Trigger:
  • Creep Spawner A
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Dying unit)) Equal to Footman
      • (Number of units in (Units in (Playable map area) matching ((Unit-type of (Dying unit)) Equal to Footman))) Equal to 0
    • Actions
      • Wait 30.00 seconds
      • Set Temp_point_A = (Center of (Playable map area))
      • Unit - Create 1 Footman for Neutral Hostile at Temp_point_A facing Default building facing degrees
      • Custom script: call RemoveLocation (udg_Temp_Point_A)


Trigger:
  • Creep Spawner B
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Dying unit)) Equal to Knight
      • (Number of units in (Units in (Playable map area) matching ((Unit-type of (Dying unit)) Equal to Knight))) Equal to 0
    • Actions
      • Wait 30.00 seconds
      • Set Temp_point_A = (Center of (Playable map area))
      • Unit - Create 1 Knight for Neutral Hostile at Temp_point_A facing Default building facing degrees
      • Custom script: call RemoveLocation (udg_Temp_Point_A)


I'm planning on having many other spawn triggers like this and don't want to have to redue all of them if its wrong.

Thanks!
 

Hellohihi

New Member
Reaction score
42
Yes they work.

Alternatively you can use:

custom script: local location temppoint
[your action]
custom script: call RemoveLocation(temppoint)
custom script: set temppoint = null

That ensures 100% mui.
But your current trigger works fine btw.
 

T.s.e

Wish I was old and a little sentimental
Reaction score
133
custom script: local location temppoint
[your action]
custom script: call RemoveLocation(temppoint)
custom script: set temppoint = null
And how were you thinking for him to reference that variable? It won't show up in the GUI variable selection.

The correct way to use pseudolocals, is to do this:
Trigger:
  • Custom Script: local location udg_YourVariableName

Which allows you to reference the variable through the drop-down list.
Remember to destroy the location though.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      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