Please read all the way thru. I do not want trigger help; rather, the safety concern I have with a certain way to pass data.
When i made a spell and re-analyze it for improvements, i decided that the best way to pass my data, that i received from the condition function, is to use a global variable.
Take a look at the script at the bottom.
Pay close attention to how <DATA> is being pass from MyCondition to MyAction.
Assumming that no unit activate the script in exactly the same moment and that <DATA> main purpose is a one-time-usage/link, then is the method, that i decided on, safe from unintended-global-override? Also, <DATA> will not be used for any other trigger other than its associated condition and action functions.
Right now, I'm assuming its safe... since its unlikely that any two unit will activate the script at the exact same moment. And that, the only possible way to get such an accurate and reliable timing is to synchronize the trigger.
When i made a spell and re-analyze it for improvements, i decided that the best way to pass my data, that i received from the condition function, is to use a global variable.
Take a look at the script at the bottom.
Pay close attention to how <DATA> is being pass from MyCondition to MyAction.
JASS:
-------------------------------------------------------------------------
globals
integer DATA = 0
endglobals
-------------------------------------------------------------------------
function MyCondition takes nothing returns boolean
//local integer i = GetSpellAbilityId()
//if i == <Some Number> then
set DATA = 1
//return true
//endif
//return false
endfunction
-------------------------------------------------------------------------
function MyAction takes nothing returns nothing
local integer i = DATA
//call DisplayTextToForce( Players(0), I2S(i))
endfunction
-------------------------------------------------------------------------
function MyTrigger takes unit a returns nothing
//local trigger t = CreateTrigger()
//call TriggerRegisterUnitEvent( t, a, EVENT_UNIT_SPELL_EFFECT)
//TriggerAddCondition( t, Condition( function MyCondition))
//TriggerAddAction( t, function MyAction)
//set t = null
endfunction
Assumming that no unit activate the script in exactly the same moment and that <DATA> main purpose is a one-time-usage/link, then is the method, that i decided on, safe from unintended-global-override? Also, <DATA> will not be used for any other trigger other than its associated condition and action functions.
Right now, I'm assuming its safe... since its unlikely that any two unit will activate the script at the exact same moment. And that, the only possible way to get such an accurate and reliable timing is to synchronize the trigger.