Doomhammer
Bob Kotick - Gamers' corporate spoilsport No. 1
- Reaction score
- 67
Before using stacks:
After implementing timer stacks:
what it does: the global timer udg_Dialog_Timer counts 30 game seconds, the local timer in this function keeps calling its function, i.e. itself every 2 game seconds, until the global timer has less than 1 sec remaining.
My problem: way 1 works nicely repeating 15 cycles, way 2 counts 2 cycles and gives up. What's wrong here?
JASS:
function TimerPeriod takes nothing returns nothing
local timer t2=GetExpiredTimer()
local timer t=CreateTimer()
call DestroyTimer(t2)
set t2=null
if (TimerGetRemaining(udg_Dialog_Timer)>1.0) then
call StartSound( gg_snd_BattleNetTick )
call TimerAura()
call TimerStart(t, 2.0, false, function TimerPeriod)
else
call DestroyTimer(t)
endif
set t=null
endfunction
call TimerStart(udg_Dialog_Timer, 30.00, false, null)
call ExecuteFunc("TimerPeriod")
After implementing timer stacks:
JASS:
function TimerPeriod takes nothing returns nothing
local timer t=NewTimer()
call ReleaseTimer(GetExpiredTimer())
if (TimerGetRemaining(udg_Dialog_Timer)>1.0) then
call StartSound( gg_snd_BattleNetTick )
call TimerAura()
call TimerStart(t, 2.0, false, function TimerPeriod)
else
call ReleaseTimer(t)
endif
endfunction
call TimerStart(udg_Dialog_Timer, 30.00, false, null)
call ExecuteFunc("TimerPeriod")
what it does: the global timer udg_Dialog_Timer counts 30 game seconds, the local timer in this function keeps calling its function, i.e. itself every 2 game seconds, until the global timer has less than 1 sec remaining.
My problem: way 1 works nicely repeating 15 cycles, way 2 counts 2 cycles and gives up. What's wrong here?