What variables does run trigger pass and how does the trigger being run handle not finding variables?
I have a unit that starts a trigger. That trigger runs another trigger. Will trigger 2 know triggering unit? Will trigger 2 freak out if it asks for a triggering unit and doesn't get one, or will it just skip that action?
If that variable is not passed, are manually set local variables passed? So I could set my triggering unit to a local variable and then use that local variable in trigger 2?
Global variables would not work as they would over wright eachother.
Edit:
Figured out that all variables are passed (it was a different trigger that was giving me my strange results when I tried to test it). Still don't know what happens when a trigger asks and doesn't get an answer.
I don't know how you figured out that they are passed but this seems wrong, i mean it shouldn't happen, especially locals.
Things like Last created unit and "maybe" triggering unit are Globals but locals there's no chance they are passed. Even if it did work its bad way of doing this. Instead you can create custom action with parameter of that unit or variables you need to pass and just copy paste actions from your secondary trigger. Custom actions are, imo, more flexible triggers. (because you can pass variables :) )
Ah, I see. Local variables are not passed, but triggering unit, etc. are passed.
I don't think they are global however, as any global variable is easily overwritten if you use any wait functions. If my computer terminology is correct, I believe they are local, but viewable by children (triggers that get run), whereas local variables are local and protected (not viewable by children).
Ah, I see. Local variables are not passed, but triggering unit, etc. are passed.
I don't think they are global however, as any global variable is easily overwritten if you use any wait functions. If my computer terminology is correct, I believe they are local, but viewable by children (triggers that get run), whereas local variables are local and protected (not viewable by children).
Triggering ... is global and will be overwritten by new events.
Running Triggers won't pass anything. Global variables stay accessible.
It's better to use action definitions because you can pass variables to them.
Also running triggers doesn't seem to execute the code in the trigger constantly because a new thread is generated which seems to run after other new threads.
So it's highly unsafe to use "triggering ..." after a wait.
edit:
new knowledge:
Some information are indeed saved. But not all.
I selected SCV 1, and right after I selected SCV 2. After 5 seconds, SCV 1 dies, and briefly after, SCV 2 dies. I've never had trouble with using Triggering Unit after waits, although I still prefer to set a local variable to it just because I think triggering unit would be an unnecessary function call to make more than once. It's Last Created Unit and such that obviously aren't safe after waits. I would call it broken if things were otherwise than this.
Edit: I just tried similar with chat event. Any player enter chat string containing "Hamster "
I type "Hamster Boo" and then "Hamster Ball". 8.0 seconds later, I get my debug message with Entered Chat String saying "Hamster Boo", and shortly after "Hamster Ball" in the correct order and all. Seems to work aswell.
Edit: I don't mean to be after you or anything. It just bugs me a little bit to hear this I call a rumor. I tested because it wouldn't be the first time if I felt doubtless while being wrong.
My point is that "triggering ..." is not overwritten (as proven by HuggetSukker's tests), as it is individual to each instance of a trigger (whereas global variables are not) and that if you use the run trigger action, you can still use "triggering ..." in the trigger being run. This means "triggering ..." is neither strictly local nor strictly global. In light of those two facts, I don't see why it would be unsafe to use it (the only possibility being a limit to the number of "triggering ..."s available at a time, but that would just be stupid design).
@HuggetSukker
Another test to run would be:
Event
Any unit is selected by player any player
Actions
Run trigger next trigger
Event
Actions
Wait 5.0 game time seconds
Kill (Triggering Unit)
Just to show that it is safe even after "run trigger"
I'm 100% sure that I've already helped some people having problems regarding "triggering player" in 1 trigger. They had errors with triggering player.
I just tested it, if the unit dies, the references do not work anymore. So triggering player will be set to "-1", if the unit dies in the meantime (I've used unit enters region as event).
So not everything seems to be saved. "Unit enters region" might only save region and unit. At least it does indeed save a unit reference.
In the end I still wouldn't use it, but anyway, thanks for sharing your knowledge and clearing things up. :)
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
What variables does run trigger pass and how does the trigger being run handle not finding variables?
I have a unit that starts a trigger. That trigger runs another trigger. Will trigger 2 know triggering unit? Will trigger 2 freak out if it asks for a triggering unit and doesn't get one, or will it just skip that action?
If that variable is not passed, are manually set local variables passed? So I could set my triggering unit to a local variable and then use that local variable in trigger 2?
Global variables would not work as they would over wright eachother.
Edit: Figured out that all variables are passed (it was a different trigger that was giving me my strange results when I tried to test it). Still don't know what happens when a trigger asks and doesn't get an answer.
I don't know how you figured out that they are passed but this seems wrong, i mean it shouldn't happen, especially locals.
Things like Last created unit and "maybe" triggering unit are Globals but locals there's no chance they are passed. Even if it did work its bad way of doing this. Instead you can create custom action with parameter of that unit or variables you need to pass and just copy paste actions from your secondary trigger.
Custom actions are, imo, more flexible triggers. (because you can pass variables :) )
Ah, I see. Local variables are not passed, but triggering unit, etc. are passed.
I don't think they are global however, as any global variable is easily overwritten if you use any wait functions. If my computer terminology is correct, I believe they are local, but viewable by children (triggers that get run), whereas local variables are local and protected (not viewable by children).
Triggering ... is global and will be overwritten by new events.
Running Triggers won't pass anything. Global variables stay accessible.
It's better to use action definitions because you can pass variables to them.
Also running triggers doesn't seem to execute the code in the trigger constantly because a new thread is generated which seems to run after other new threads.
So it's highly unsafe to use "triggering ..." after a wait.
edit:
new knowledge:
Some information are indeed saved. But not all.
Triggering Unit is clearly not overwritten.
I put 2 SCVs in a map and made a test trigger:
I selected SCV 1, and right after I selected SCV 2. After 5 seconds, SCV 1 dies, and briefly after, SCV 2 dies. I've never had trouble with using Triggering Unit after waits, although I still prefer to set a local variable to it just because I think triggering unit would be an unnecessary function call to make more than once. It's Last Created Unit and such that obviously aren't safe after waits. I would call it broken if things were otherwise than this.
Edit: I just tried similar with chat event. Any player enter chat string containing "Hamster "
I type "Hamster Boo" and then "Hamster Ball". 8.0 seconds later, I get my debug message with Entered Chat String saying "Hamster Boo", and shortly after "Hamster Ball" in the correct order and all. Seems to work aswell.
Edit: I don't mean to be after you or anything. It just bugs me a little bit to hear this I call a rumor. I tested because it wouldn't be the first time if I felt doubtless while being wrong.
@Ahli634
My point is that "triggering ..." is not overwritten (as proven by HuggetSukker's tests), as it is individual to each instance of a trigger (whereas global variables are not) and that if you use the run trigger action, you can still use "triggering ..." in the trigger being run. This means "triggering ..." is neither strictly local nor strictly global. In light of those two facts, I don't see why it would be unsafe to use it (the only possibility being a limit to the number of "triggering ..."s available at a time, but that would just be stupid design).
@HuggetSukker
Another test to run would be:
Event
Actions
Event
Actions
Just to show that it is safe even after "run trigger"
I'm 100% sure that I've already helped some people having problems regarding "triggering player" in 1 trigger. They had errors with triggering player.
I just tested it, if the unit dies, the references do not work anymore. So triggering player will be set to "-1", if the unit dies in the meantime (I've used unit enters region as event).
So not everything seems to be saved. "Unit enters region" might only save region and unit. At least it does indeed save a unit reference.
In the end I still wouldn't use it, but anyway, thanks for sharing your knowledge and clearing things up. :)