[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Bug reports
. . -> [Subject]  Can NOT SetTimerOption for "second"

Can NOT SetTimerOption for "second"

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Jcl2016   (8 posts)  [Biography] bio
Date Mon 28 Nov 2016 03:12 AM (UTC)
Message
No matter what I set to the "second" option, the timer will be triggered at 0 second.


SetTimerOption("xxx", "second", 9)
Note(GetTimerOption("xxx", "second"))  -- result is 0.
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Mon 28 Nov 2016 04:16 AM (UTC)
Message
I can't reproduce that. I got "9" printed.

Template:version Please help us by advising the version of MUSHclient you are using. Use the Help menu -> About MUSHclient.


Does the timer exist? What scripting language are you using?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Jcl2016   (8 posts)  [Biography] bio
Date Reply #2 on Mon 28 Nov 2016 05:42 AM (UTC)
Message
Nick Gammon said:

I can't reproduce that. I got "9" printed.

(version)

Does the timer exist? What scripting language are you using?


Version 5.02. The scripting language is Lua.

The timer is definitely there,it is "at the time" timer.

( The "every interval" timer is correct. )
[Go to top] top

Posted by Fiendish   USA  (2,514 posts)  [Biography] bio   Global Moderator
Date Reply #3 on Mon 28 Nov 2016 05:38 PM (UTC)
Message
I also can't reproduce this. Just for completeness, can you verify that copying/pasting this code exactly still prints 0 instead of 9?

AddTimer("xxx", 0, 0, 1.5, "", timer_flag.OneShot, "")
SetTimerOption("xxx", "second", 9)
Note(GetTimerOption("xxx", "second"))

https://github.com/fiendish/aardwolfclientpackage
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #4 on Mon 28 Nov 2016 08:56 PM (UTC)
Message
I can reproduce it with an "at" timer. There is definitely a bug there, introduced when the seconds field became a floating point (so you can have 0.1 seconds).

I suggest as a work-around that you delete and re-add the timer. Or use "addxml.lua" module: http://www.gammon.com.au/forum/?id=7123

For example:


require "addxml"
addxml.timer {  at_time = true,
                hour = 23, minute = 15, second = 16.8,
                send = "Timer fired!",
                send_to = sendto.output,
                enabled = true,
                name = "whatever",
              }


If you give a name to the timer it replaces another one of the same name (if any).

However perhaps you don't really want an "at" timer? I think this has gone unreported for so long because usually an "at" timer is for stuff like rotating your log files once a day, at midnight, and no-one cares if it is done at midnight or midnight + 5 seconds.

If you are trying to know when something happens in the near future (where 9 seconds would make a difference) like when a spell wears off, you are probably better off with an "every" timer, and make it "one-shot". A one-shot timer fires once and then deletes itself. This would be easier anyway because you probably know the interval, and using an "at" timer means you have to take the interval, add in the time right now, and get the time in the future when you want it to fire.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Fiendish   USA  (2,514 posts)  [Biography] bio   Global Moderator
Date Reply #5 on Mon 28 Nov 2016 10:00 PM (UTC)
Message
Nick Gammon said:

I can reproduce it with an "at" timer.

Oh, is that what '"at the time" timer' meant. I totally missed that.

https://github.com/fiendish/aardwolfclientpackage
[Go to top] top

Posted by Jcl2016   (8 posts)  [Biography] bio
Date Reply #6 on Tue 29 Nov 2016 04:14 AM (UTC)
Message
Nick Gammon said:

I can reproduce it with an "at" timer. There is definitely a bug there, introduced when the seconds field became a floating point (so you can have 0.1 seconds).

I suggest as a work-around that you delete and re-add the timer. Or use "addxml.lua" module: http://www.gammon.com.au/forum/?id=7123


Thank you for your suggest, I will try it.

I really want the "at" timers.

An event will occur at a specific time. It's MUD server's time. I need to do something before the event and keep idle for a while. And then I need to do another thing after the specific time, no matter whether the event occurred or not.

For example, I need two "at" timers fire at 10:00:25 and 10:00:35 respectively. Unfortunately, the plugin will run on multiple machines, and the system time of each machine is not the same. So I need SetTimerOption to adjust the fire time dynamically.
As the bug you know, two timers were both be set to 10:00:00 and fired at the same time.
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #7 on Sun 11 Dec 2016 09:09 PM (UTC)
Message
Fixed in version 5.04.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] 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.


19,686 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]