• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

[JASS] Jass Timers

Status
Not open for further replies.
Level 5
Joined
Jul 17, 2006
Messages
145
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:

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

Instead of that i would like to use something like

Code:
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 :)
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
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

JASS:
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.
 
Status
Not open for further replies.
Top