• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

help with TimerStart function

Status
Not open for further replies.
Level 3
Joined
Mar 2, 2008
Messages
62
im trying to make a mui spell that uses a timer. i came across this in the jass api:


JASS:
native TimerStart (timer whichTimer, real timeout, boolean periodic, code handlerFunc) returns nothing

im not too good with jass, and i dont understand the whole thing about handle functions. anyway, if i want to pass this function another function (say i want it to run function d as the code)

what do i need to do to get function d to run whenever the timer expires?

(how do i use this function properly?)
 
Level 2
Joined
Jun 15, 2007
Messages
12
im trying to make a mui spell that uses a timer. i came across this in the jass api:


JASS:
native TimerStart (timer whichTimer, real timeout, boolean periodic, code handlerFunc) returns nothing

im not too good with jass, and i dont understand the whole thing about handle functions. anyway, if i want to pass this function another function (say i want it to run function d as the code)

what do i need to do to get function d to run whenever the timer expires?

(how do i use this function properly?)


JASS:
function IRunWhenTheTimerExpires takes nothing returns nothing
debug call BJDebugMsg("Hello world.")
endfunction

function IStartTheTimer takes nothing returns nothing
local timer t = CreateTimer()

call TimerStart(t, 1, true, function IRunWhenTheTimerExpires)

endfunction
 
Level 3
Joined
Mar 2, 2008
Messages
62
does the IRunWhenTimerExpires function in the example above have to take and return nothing? or can i pass it a few variables.

also do these variables get reset every time> or do they stay as they are
 
Level 2
Joined
Jun 15, 2007
Messages
12
does the IRunWhenTimerExpires function in the example above have to take and return nothing? or can i pass it a few variables.

also do these variables get reset every time> or do they stay as they are

Timer callback functions can't take or return anything. There are alot of systems available for passing stuff to callbacks


Which variables are you talking about?
 
does the IRunWhenTimerExpires function in the example above have to take and return nothing? or can i pass it a few variables.

also do these variables get reset every time> or do they stay as they are
Haha, if they would be able to return something we do not have the problems with vJASS and the handle system. :p
 
Level 3
Joined
Mar 2, 2008
Messages
62
Timer callback functions can't take or return anything. There are alot of systems available for passing stuff to callbacks


Which variables are you talking about?

i was talking about the local variables created in the function.

and thanks for your help, i get it now.
 
Status
Not open for further replies.
Top