HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Timers never resume...

04-16-2008, 08:24 PM#1
darkwulfv
Collapse JASS:
      call PauseTimer(SpawnTimer)
      call PauseTimer(BossTimer)
      call PolledWait(25.)
      call ResumeTimer(SpawnTimer)
      call ResumeTimer(BossTimer)

Here's the function that starts those timers:

Collapse JASS:
  call TimerStart(SpawnTimer, 8. + (PlayerNum * 2), true, function Master_Spawn_Func)
  //call TimerStart(BossTimer, 38. + (PlayerNum * 2), true, function Boss_Spawn_Func)
(BossTimer is commented out for a reason)

I think it has something to do with PolledWait, but I'm not sure. The calls for Pause/ResumeTimer are in the function each timer calls when they expire.
I'm pausing these timers because it's a wave game, and all the spawns run off of one timer. So at the end of each wave, the timers pause, players get 25 seconds to heal, then the timers resume and the next wave starts (well, that's what it's supposed to do. The timers don't resume, so nothing happens =/)

Could BossTimer not being a started timer mean anything? It's a created timer, but not started. Would pausing it cause a thread crash or anything like that?
04-16-2008, 08:34 PM#2
Rising_Dusk
Make sure your thread isn't crashing because of the PolledWait(). If this is done in a timer callback, it will crash and the ResumeTimer() won't even get called.
04-16-2008, 08:39 PM#3
darkwulfv
Oh, it will? Then that's the problem. (PolledWait() in a timer callback) Do you have any idea how I could fix it? Could a timer with a .01 callback that links to another function which pauses those timers, then starts ANOTHER timer which would resume them. It's tacky, but that's what I could think of. Is there a better way to go about it?
04-16-2008, 08:43 PM#4
Vexorian
You could just do:

Collapse JASS:


function ResumeSpawnTimer takes nothing returns nothing
     call TimerStart(SpawnTimer, 8. + (PlayerNum * 2), true, function Master_Spawn_Func)

endfunction

//...

  call TimerStart(SpawnTimer, 25.0, false, function ResumeSpawnTimer)

04-16-2008, 09:06 PM#5
Rising_Dusk
See above, Vex's method is what I use for timers starting timers. You could also call TimerStart() on GetExpiredTimer() and it works perfectly fine.
04-16-2008, 09:41 PM#6
darkwulfv
Okay, let me see...

So, I start SpawnTimer as a 25 second timer. After it goes off, it starts SpawnTimer as a periodic 8+# timer. Once it's run its course the number of times I want it to (12), I stop the timer and then... call the function that initiates SpawnTimer as a 25 second timer?
04-16-2008, 09:44 PM#7
Rising_Dusk
Quote:
Originally Posted by darkwulfv
So, I start SpawnTimer as a 25 second timer. After it goes off, it starts SpawnTimer as a periodic 8+# timer. Once it's run its course the number of times I want it to (12), I stop the timer and then... call the function that initiates SpawnTimer as a 25 second timer?
Call the function at the end using ExecuteFunc() since it will have to be below the other function in the .j file. But yes, that will work.
Attached Images
File type: gifHero3_First.gif (1.1 KB)
04-16-2008, 09:45 PM#8
PandaMine
Never have waits in a timer callback, it will either create tremendous lag or crash the thread

Just use if-then-else statements with a counter if you wanna manage different instances in a timer or do what Vex did
04-16-2008, 10:04 PM#9
darkwulfv
I'm doing what Vex and Dusk recommended. It looks easy and helpful.

And a bit of what you suggested to. I have a counter that keeps track of the number of times the timer has fired, and once it fires X times I'll stop it and resume it.

ExecuteFunc takes a string, right? So it would be ExecuteFunc("Timer_Whatever"), right?

Thanks for the help. Waits in my timers is probably why a lot of my previous attempts with timers failed so miserably.
04-16-2008, 10:05 PM#10
Vexorian
Quote:
Never have waits in a timer callback, it will either create tremendous lag or crash the thread
I really thought it always crashed the thread.
Attached Images
File type: pngnewvxicon48.png (3.6 KB)
File type: pngjasshelper48.png (873 bytes)
File type: gifHero3_Second.gif (1.1 KB)