Warcraft III resources & community, 2003–2006 · archived

Jass Timers

3 posts
#1

Jass Timers

Is there a way i can get the TimerStart function to accept parameters in the last parameter (lol, i didetn really word that well did i) example:

call TimerStart(t, 0.01, true, function Knockback)


Instead of that i would like to use something like

call TimerStart(t, 0.01, true, function Knockback(parameters))


(assuming the function your running has parameters)

The only problem with that, is iv tried doing it and it returns a syntax error O_o

Any help is apprecated :)
#2
thats what the Local Handle Variables are for.

They basically allow you to tag on values to handles, through a global gamecache.

An example of how to use them

function Knockback takes nothing returns nothing
    local timer ThisIsAnotherHandle = GetExpiredTimer()
    local real r = GetHandleReal( ThisIsAnotherHandle, "thisisastring" )
endfunction

function KnockbackInit takes nothing returns nothing
    local timer ThisIsAHandle = CreateTimer()
    call SetHandleReal( ThisIsAHandle, "thisisastring", 999999999.999 )
    call TimerStart( ThisIsAHandle, 0.001, true, function Knockback )
endfunction


Note that i named the variables so that theyre easy to figure out what goes where :D

Also, note that instead of having a seperate function for Lightning, Unit, Group, and all the works, there is SetHandleHandle, but you have to get the individual types, as handles themselves ( not child-types however ) arent very useful on their own :P

PS. To clean up the functions, in the [STOP, TIMER!] part of your timer function, along with PauseTimer and DestroyTimer ( above DestroyTimer, though ), put FlushHandleLocals( timer ), where timer is a timer.
#3
Hmm, i think i get how to do it now. Thanks :)