• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Are local variables passed in the Run Trigger?

Status
Not open for further replies.
Level 1
Joined
Nov 12, 2007
Messages
7
I am making a trigger that will execute another trigger to take the triggering player and return the triggering player's unit (each player has 1 unit). Simply put, trigger 1 runs trigger 2. Can trigger 2 access trigger 1's triggering player, or will I have to store it in a global variable?

Edit: I have tested it, and it seems to work, but I'm asking because I am worried that it is only working because I am the only player.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
No its working fine. The broken value to return is 0 which corosponds to a neutral unplayable player.

What you are doing is prety bad coding practice however. Rather make the second trigger a function as a function is less complex that a trigger. Locals persisit the entire length of the function call and are thread specific (locals are different between threads). Values like triggering player are thread specific and always acessible no mater how complex the stack become as long as the same thread is running.

Be aware that there is an op limit in place which will prevent a thread from running too much code.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
To english'ize what DSG said, I don't think it will transfer between triggers.
Event values like triggering unit do transfer between triggers if 1 runs the other.
Local variables do not as they obey the normal rules of locals (placed to thread stack each function call).

Also instead of taking up too much space making two seperate triggers, make it all into one. Remember the [If, Then, Else] function comes in handy here.
You have to be careful not to produce too much procedural coupling when doing that though as it can make programming and maintence harder than it needs to be.

Be aware there is a limit to how many functions can be in a single trigger.
There is no actual limit as long as you do not nest function calls too deep as that could cause a stack overflow. There is a limit on the number of opperations a thread can run "immediatly" known as the op limit though.
 
Last edited:
Status
Not open for further replies.
Top