Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ General
➜ does this SafeWait make sense?
|
does this SafeWait make sense?
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Jing Wu
Australia (35 posts) Bio
|
| Date
| Fri 03 May 2013 07:50 AM (UTC) |
| Message
|
function CommandSender:SafeWait(interval)
if interval < 0.1 then
interval = 0.1 -- wait minimum unit is 0.1 second
end
local startTime = socket.gettime()
wait.time(interval)
local usedTime = socket.gettime() - startTime
interval = interval - usedTime
if interval > 0 then
ColourNote("white", "red", "wait used:" .. usedTime .. ", required more delay:" .. interval)
self:SafeWait(interval)
end
end
I found that wait.time sometimes returns earlier than the actual wait time, because, I guess, windows message issues?
Cheers,
Jing |
Kernel Development | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #1 on Sat 04 May 2013 07:14 AM (UTC) |
| Message
| I think I would loop rather than recurse, just to be on the safe side.
You should be able to use the high-precision timer (see utils.timer) to see how much time has elapsed. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Jing Wu
Australia (35 posts) Bio
|
| Date
| Reply #2 on Sat 04 May 2013 09:10 AM (UTC) |
| Message
| socket.gettime should do the same thing as utils.timer does.
From the test, I can see sometimes ColourNote outputs.
so can I say that wait.time is not reliable?
Cheers,
Jing |
Kernel Development | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #3 on Sun 05 May 2013 10:29 AM (UTC) |
| Message
| | It should be reliable, however timers are implemented with a 0.1 second granularity. I would be interested to see your exact figures for what you think is "not reliable". |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
15,067 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top