HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Wait alternative function?

04-19-2007, 08:16 PM#1
Ghost.X
Is there an alternative wait function I can use or create that can count as low as 0.04 or around as low as that? The functions such as TriggerSleepAction and PolledWait have limits. I need a wait function I can use in a counter loop cause those functions are just too slow.

Or would it be a better alternative to use another trigger that uses the peridodic event timer? As far as I know, you can only do this by creating one trigger that turns on the periodic timer trigger with the event of the unit casting the spell? Perhaps it will be a better alternative if I set global variables in the first trigger, turns on the periodic trigger, then that trigger converts those global variables into local variables. But would there be conflict in using a periodic timer trigger to carry out a spell in the event that two players cast the spell at or around the same time?

I'm finally decided to get into jass, so i'm noob right now. But I understand the whole syntax thing.
04-19-2007, 11:04 PM#2
Earth-Fury
Collapse JASS:
function dostuff takes nothing returns nothing
    // actions in your timed loop
endfunction

function start_loop takes nothing returns nothing
    local timer t = CreateTimer()
    call TimerStart(t, 0.04, true, function dostuff)
    set t = null
endfunction
Use a periodic timer. (the "true" paramiter in TimerStart() makes it a periodic timer)
04-20-2007, 06:01 PM#3
Ghost.X
Hmm, but if the boolean is true, then will the funtion keep running over and over? Is there a way to make the function run only a certain amount of times?
04-20-2007, 06:16 PM#4
Earth-Fury
You can pause and distroy the timer. eg:
Collapse JASS:
function dostuff takes nothing returns nothing
    // actions in your timed loop
    if var == true then
        call PauseTimer(GetExpiredTimer())
        call DestroyTimer(GetExpiredTimer())
    endif
endfunction

function start_loop takes nothing returns nothing
    local timer t = CreateTimer()
    call TimerStart(t, 0.04, true, function dostuff)
    set t = null
endfunction

or restart the same timer again and again in the callback function.
04-20-2007, 06:43 PM#5
Ghost.X
k thats super useful, i'd give yah rep if i could. what does the "you need to spread rep" mean anyways?
04-20-2007, 06:44 PM#6
akolyt0r
you have to give rep to other people first before you can rap earth fury again...(i assume ..)
04-20-2007, 06:56 PM#7
Ghost.X
oh i get it, +rep thanks XD!