 |
WC3Jass.com "The Jass Vault"
|
Affiliates
|
| Script code |
function PolledWait takes real duration returns nothing
local timer t
local real timeRemaining
if (duration > 0) then
set t = CreateTimer()
call TimerStart(t, duration, false, null)
loop
set timeRemaining = TimerGetRemaining(t)
exitwhen timeRemaining <= 0
// If we have a bit of time left, skip past 10% of the remaining
// duration instead of checking every interval, to minimize the
// polling on long waits.
if (timeRemaining > bj_POLLED_WAIT_SKIP_THRESHOLD) then
call TriggerSleepAction(0.1 * timeRemaining)
else
call TriggerSleepAction(bj_POLLED_WAIT_INTERVAL)
endif
endloop
call DestroyTimer(t)
endif
endfunction
|
|
 |
|
| Script info |
| Name: |
PolledWait |
| Author: |
Blizzard |
| Submitted: |
Sun Nov 28, 2004 8:30 pm |
| Lines: |
22 |
| Functions: |
|
|
|
| Description |
|
|
 |
|
 |
|
 |
 |
|
 |
|
|
| Message |
Posted:
Sat Jul 16, 2005 11:54 pm Post subject:
|
|
|
I cannot see why bliz make it loop so many times...
Would there be any bug if I write it like this :
| Code: |
function PolledWait takes real duration returns nothing
local timer t = CreateTimer()
local real timeRemaining
call TimerStart(t, duration, false, null)
loop
set timeRemaining = TimerGetRemaining(t)
exitwhen timeRemaining <= 0
call TriggerSleepAction(timeRemaining)
endloop
call DestroyTimer(t)
endfunction
|
|
|
|
|
 |
|
|
|
| Message |
Posted:
Sun Jul 17, 2005 10:46 am Post subject:
|
|
|
| It would be less accurate because game time is usually much faster than real time (depends on game speed), so your TriggerSleepAction would simply wait for too long. |
|
|
|
 |
|
|
You cannot submit new scripts in this section You can comment on scripts in this section You cannot edit your scripts in this section You cannot delete your scripts in this forum
|
|