HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Flushing Local Vars in Kattana's system

07-27-2007, 03:06 AM#1
Immoralis
When I did this, "yea" was displayed but the FlushHandleLocals(end) did not work so the unit kept sliding. I was wondering how to flush it so the unit would stop sliding.

Collapse JASS:
function Destroy_Sliding takes nothing returns nothing
    local timer end = GetExpiredTimer()
    call DisplayTextToForce(GetPlayersAll(),"yea")
    call FlushHandleLocals(end)
    call DestroyTimer(end)
    set end = null
endfunction


function MakeUnitSlide takes unit static, unit dynamic, real time returns nothing
    local timer t = CreateTimer()
    local timer end = CreateTimer()
    local unit caster = static
    local unit target = dynamic
    call SetHandleHandle(t, "caster", caster)
    call SetHandleHandle(t, "target", target)
    call TimerStart(t, 0.033, true, function Execute_MakeUnitSlide)
    //call DisplayTextToForce(GetPlayersAll(),"ended")
    call TimerStart(end, time, false, function Destroy_Sliding)
endfunction

The following did not work because for some reason call PolledWait(time) was infinitly long. I tried to make it display "time" and it said 1.5 seconds. I knew it was infinitly long because I put a display after it and it never showed. This problem prompted me to do the above part.

Collapse JASS:
function MakeUnitSlide takes unit static, unit dynamic, real time returns nothing
    local timer t = CreateTimer()
    local unit caster = static
    local unit target = dynamic
    call SetHandleHandle(t, "caster", caster)
    call SetHandleHandle(t, "target", target)
    call TimerStart(t, 0.033, true, function Execute_MakeUnitSlide)
    call PolledWait(time)
    call FlushHandleLocals(t)
    call DestroyTimer(t)
    set t = null
endfunction
07-27-2007, 03:21 AM#2
Pyrogasm
Always pause a timer with call PauseTimer(whichTimer) before destroying it. Even a destroyed timer can, in some cases, continue to expire.
07-27-2007, 03:42 AM#3
PipeDream
  • You never stop the sliding timer "t"
  • You likely call MakeUnitSlide() from a timer expiration or TriggerEvaluate, which war3 does not permit
07-27-2007, 04:34 AM#4
Immoralis
how would i stop timer t after end expires?


Edit: I got it working, I attached t to end and stopped it at Destroy_Sliding :)