HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Why is TriggerSleepAction so slooooow?

07-21-2006, 03:12 PM#1
StockBreak
Hi all, I am using this horrible function just because I have already too much created triggers on my new spell. The problem is that this function it's not precise at all, I mean I use wait of 1 second, not 0.01 and it still delays as hell ! In example I have a loop which is similar to it:
Collapse JASS:
loop
    exitwhen( counter == 10 )
    call DisplayTextToForce( GetPlayersAll(  ), I2S( counter ) )
    call TriggerSleepAction( 1 )
    set counter = counter + 1
endloop
It requires about 15 seconds to be executed, why? Thanks.

P.S: please don't tell me to use timers, I already know...
07-21-2006, 03:33 PM#2
Captain Griffen
Because it uses real time, rather than game time. Use PolledWait for a better version, and timers for precision.
07-21-2006, 03:35 PM#3
iNfraNe
periodic event or timers.
07-21-2006, 05:12 PM#4
The)TideHunter(
Quote:
Originally Posted by StockBreak
P.S: please don't tell me to use timers, I already know...

Quote:
Originally Posted by iNfraNe
periodic event or timers.
07-21-2006, 05:27 PM#5
Anitarf
Quote:
Originally Posted by StockBreak
P.S: please don't tell me to use timers, I already know...
If you know, then why ask?
07-21-2006, 08:20 PM#6
PipeDream
PolledWait won't do much better, but with long delays you don't need to use a callback and their attendant cruft. An inlined polledwait will work:
Collapse JASS:
local timer t = CreateTimer()
call TimerStart(t,30.,false,null)
loop
  exitwhen counter >= 10
  if TimerGetElapsed(t) >= counter then
    call DisplayTextToPlayer(GetLocalPlayer(),0.,0.,I2S(counter))
    set counter = counter + 1
  endif
  call TriggerSleepAction(0.)
endloop
call DestroyTimer(t)
set t = null
07-22-2006, 02:20 AM#7
Sharingan
Agreed.
PolledWaits are even worse in my opinion, because at the end, it still uses TriggerSleepAction.
07-22-2006, 08:38 AM#8
The)TideHunter(
Polledwaites have the advantages, such as gametime rather than realtime, it uses a timer, and "can" sometimes be more accurate.
07-22-2006, 11:52 AM#9
Vexorian
Quote:
Originally Posted by Sharingan
Agreed.
PolledWaits are even worse in my opinion, because at the end, it still uses TriggerSleepAction.
It is not like using TriggerSleepAction would cause your map a flu , PolledWait is better because it uses TriggerSleepAction wiselly, so it is much more accurate, unless you use it for low values, but heck, if you need small delays to be accurate you have to use timers
07-22-2006, 12:17 PM#10
StockBreak
Ok, I chose to create another trigger using timers. Thank you all anyway.