Hi, I've just recently started learning JASS and just wanna ask a question regarding gamecache
I read that gamecache can be used to link data and stuff to a handle. I'm trying to link two functions together. I'm refering to the tutorial JASS: Advanced Tips by Daelin.
http://world-editor-tutorials.thehelper.net/cat_usersubmit.php?view=28217
Here, the handle used to link the two functions together is a timer. However, I am intending to link two functions together to run concurrently, i.e. with no delay in between. What handle should I use for such a linkage? I'm not sure a Timer would accept a duration of 0.00 seconds and it seems rather counter-intuitive to me.
For example if I mimic the above code:
Then when the timer expires I can (hypothetically) create a separate trigger and retrieve the handle using GetExpiredTimer()... But is there a simpler way? Again as I said the use of a timer with zero duration here is very counter-intuitive to me and I'm not even sure if it works... Thus my question is: what handle should I use and what should the script look like?
I read that gamecache can be used to link data and stuff to a handle. I'm trying to link two functions together. I'm refering to the tutorial JASS: Advanced Tips by Daelin.
http://world-editor-tutorials.thehelper.net/cat_usersubmit.php?view=28217
JASS:
function Knockback takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit caster = GetHandleUnit(t, “caster”)
local unit target = GetHandleUnit(t, “target”)
local real x1 = GetUnitX(caster)
local real y1 = GetUnitY(caster)
local real x2 = GetUnitX(target)
local real y2 = GetUnitY(target)
call SetUnitPosition(target, PolarProjectionX(x1, GetDistanceBetweenPoints(x1,y1,x2,y2)+10.00, GetAngleBetweenPoints(x1,y1,x2,y2)), PolarProjectionY(y1, GetDistanceBetweenPoints(x1,y1,x2,y2)+10.00, GetAngleBetweenPoints(x1,y1,x2,y2)))
set t = null
set caster = null
set target = null
endfunction
function Execute_Knockback takes nothing returns nothing
local timer t = CreateTimer()
local unit caster = GetTriggerUnit()
local unit target = GetSpellTargetUnit()
call SetHandleHandle(t, “caster”, caster)
call SetHandleHandle(t, “target”, target)
call TimerStart(t, 0.035, true, function Knockback)
call TriggerSleepAction(0.5)
call FlushHandleLocals(t)
call DestroyTimer(t)
set t = null
set caster = null
set target = null
endfunction
Here, the handle used to link the two functions together is a timer. However, I am intending to link two functions together to run concurrently, i.e. with no delay in between. What handle should I use for such a linkage? I'm not sure a Timer would accept a duration of 0.00 seconds and it seems rather counter-intuitive to me.
For example if I mimic the above code:
JASS:
function Sample takes nothing returns nothing
local timer t = CreateTimer()
local unit caster = GetTriggerUnit()
call SetHandleInt(t,"Caster",caster)
call TimerStart(t,0,false,null)
endfunction
Then when the timer expires I can (hypothetically) create a separate trigger and retrieve the handle using GetExpiredTimer()... But is there a simpler way? Again as I said the use of a timer with zero duration here is very counter-intuitive to me and I'm not even sure if it works... Thus my question is: what handle should I use and what should the script look like?