- Joined
- Mar 15, 2005
- Messages
- 112
What am I doning wrong? Trying to learn how to use local timers to simulate a periodic event. Planned to destroy the timer after the loop.
JASS:
function Conditions takes nothing returns boolean
if ( not ( GetSpellAbilityId() == 'a000' ) ) then
return false
endif
return true
endfunction
function callback takes nothing returns nothing
call DisplayTimedTextToPlayer(GetTriggerPlayer(),0,0,60,"1")
endfunction
function Actions takes nothing returns nothing
local unit array U
local integer array I
local timer T = CreateTimer()
set U[1] = GetTriggerUnit()
call TimerStart(T,0.75,true,function callback)
set I[1] = 0
call DisplayTimedTextToPlayer(GetTriggerPlayer(),0,0,60,"1")
loop
exitwhen I[1] == 25
set I[1] = I[1] + 1
endloop
endfunction
//===========================================================================
function InitTrig_Timer takes nothing returns nothing
set gg_trg_Timer = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Timer, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Timer, Condition( function Conditions ) )
call TriggerAddAction( gg_trg_Timer, function Actions )
endfunction