Execute order

Rainther

I guess I should write something of value here...
Reaction score
61
Is there any way to make one function execute before an other? I need to pass a global variable to an other and the both are executed by the same event (unit takes damage)
 

Rainther

I guess I should write something of value here...
Reaction score
61
I honestly don't see how printing my codes answers the question. One trigger is probably triggered before the other one, and I doubt it has anything to do with the codes in the triggers.

And what does libraries have to do with anything in this case? :?

Both triggers registers incomming damage, one does calucations based on unit mana, damage absorbed and some more and calculates a number which I'd like the other function to use. However through using debug, I know that the other trigger is executed first. I tried moving position of them both in the rows, and still it executes first.

Could it be because of the order I register the events in each trigger?
 

Romek

Super Moderator
Reaction score
963
You could call the second function from within the first, instead of using a trigger for both.
I also think (untested though) that actions/conditions are executed in the order in which they are added to the trigger. So if you use a single trigger, and add them in the order you want them triggered, it could solve the problem.
As mentioned, that's untested though probable.
 

Rainther

I guess I should write something of value here...
Reaction score
61
You could call the second function from within the first, instead of using a trigger for both.
I also think (untested though) that actions/conditions are executed in the order in which they are added to the trigger. So if you use a single trigger, and add them in the order you want them triggered, it could solve the problem.
As mentioned, that's untested though probable.

The reason I don't do first mentioned is because one trigger is activated always and the other one is an created trigger with event damage, making it rather hard to implent them together.

Anyhow. I did like this and it seems as if they run in random order... Which is really wierd if you ask me.

JASS:
    call TriggerRegisterUnitEvent(t, tar, EVENT_UNIT_DAMAGED)
    call TriggerRegisterUnitEvent(t, cast, EVENT_UNIT_SPELL_EFFECT)
    call TriggerRegisterTimerEvent(t, Dur, false)
    call TriggerAddAction(t, function Act2)
    call TriggerClearConditions( gg_trg_TeamKill )
    call TriggerAddCondition( gg_trg_TeamKill, Filter(function TeamKillCons))
    call TriggerClearActions( gg_trg_TeamKill )
    call TriggerAddAction( gg_trg_TeamKill, function TeamKillAct )


gg_trg_TeamKill is supposed to run 2nd.
 

Tom Jones

N/A
Reaction score
437
Triggers will execute in the order they are declared, meaning a trigger in the start of the map code will execute before a trigger in the end of the map code. This also applies if both the triggers have the same event.

Condiitions will fire in the order they are added to the trigger.

And lastly, actions will, as conditions, fire in the order they are added to the trigger.
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
Triggers will execute in the order they are declared, meaning a trigger in the start of the map code will execute before a trigger in the end of the map code. This also applies if both the triggers have the same event.

Condiitions will fire in the order they are added to the trigger.

And lastly, actions will, as conditions, fire in the order they are added to the trigger.

And that's why i say you should use librairies and the word "uses/needs..." in order to manage the order of triggers creation.
 

Rainther

I guess I should write something of value here...
Reaction score
61
That may give me a problem since the trigger I want to be executed first is added through an ability (temporarly and recreated each use of the ability). I can't see how I'm supposed to change the order then. Maybe by recreating the first trigger.

It that doesn't do the trick I guess I'll have to redone it some.
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
That may give me a problem since the trigger I want to be executed first is added through an ability (temporarly and recreated each use of the ability). I can't see how I'm supposed to change the order then. Maybe by recreating the first trigger.

It that doesn't do the trick I guess I'll have to redone it some.
You can disable your static trigger when you create your dynamic trigger, and when your dynamic trigger is running, evaluate/execute your static trigger and finally enable your static trigger.

However it will fail if the damage event will never fire.
Depends what you want to do exactly.
 

Rainther

I guess I should write something of value here...
Reaction score
61
I believe I managed to solve this problem. I made the effect from one trigger to effect the other and that trigger is ignored if boolean is set to true.
 
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