- Joined
- Aug 7, 2013
- Messages
- 1,338
Hi,
If I understand correctly Warcraft 3 only has a single thread that runs at a time. So every single call is ordered, in that there are no two calls that run at the exact same time, and that each call needs to wait for the one before it to finish before it is executed?
Now suppose I have a (global) boolean variable. I have two separate triggers which do the exact same thing to that boolean: they set it to true only if it is false.
These two triggers also fire on the same exact event, e.g. a player unit picks up any item. Here is some example code:
As you can see, they have the exact same event conditions, but obviously different actions. So if a unit picks up an item, what will happen? Will I get both display text messages, or either only from trig1 or trig2? Will it be 'random' to me which one happens to set the flag to true first?
If I understand correctly Warcraft 3 only has a single thread that runs at a time. So every single call is ordered, in that there are no two calls that run at the exact same time, and that each call needs to wait for the one before it to finish before it is executed?
Now suppose I have a (global) boolean variable. I have two separate triggers which do the exact same thing to that boolean: they set it to true only if it is false.
These two triggers also fire on the same exact event, e.g. a player unit picks up any item. Here is some example code:
JASS:
function trig1Actions takes nothing returns false
if myBool == False then
set myBool == True
call DisplayTimedTextToPlayer(Player(0), 0, 0, 5, "trig1 entered CS!"
endif
endfunction
private function init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterPlayerUnitEventSimple(t, Player(0), EVENT_PLAYER_UNIT_PICKUP_ITEM)
call TriggerAddCondition(trig1Actions, Condition(function trig1Actions))
set t = null
endfunction
...
function trig2Actions takes nothing returns false
if myBool == False then
set myBool == True
call DisplayTimedTextToPlayer(Player(0), 0, 0, 5, "trig2 entered CS!")
endif
endfunction
private function init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterPlayerUnitEventSimple(t, Player(0), EVENT_PLAYER_UNIT_PICKUP_ITEM)
call TriggerAddCondition(trig1Actions, Condition(function trig2Actions))
set t = null
endfunction
As you can see, they have the exact same event conditions, but obviously different actions. So if a unit picks up an item, what will happen? Will I get both display text messages, or either only from trig1 or trig2? Will it be 'random' to me which one happens to set the flag to true first?