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


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Lua
. . -> [Subject]  addxml timers

addxml timers

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


Posted by ReallyCurious   USA  (50 posts)  [Biography] bio
Date Thu 24 May 2007 09:05 PM (UTC)
Message
require "addxml"
addxml.timer {name = "test1",
enabled = true,
second = 5,
send_to = 12,
one_shot = true,
send = print("hello"),
print("how are you")
}

I want to create a labeled timer similar to this but not have it fire when it's created, but to fire 5 seconds after it's created. Can I do this?
[Go to top] top

Posted by Shaun Biggs   USA  (644 posts)  [Biography] bio
Date Reply #1 on Thu 24 May 2007 11:08 PM (UTC)
Message
I think you may have found a bug. I can't get that to work properly even with setting offset_second to 5. For now, just use the DoAfterSpecial function. http://www.gammon.com.au/scripts/function.php?name=DoAfterSpecial

It is much easier to fight for one's ideals than to live up to them.
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #2 on Fri 25 May 2007 05:17 AM (UTC)
Message
You are not quoting the send text. It should read:


require "addxml"
addxml.timer {
  name = "test1",
  enabled = true,
  second = 5,
  send_to = 12,
  one_shot = true,
  send = [[
print("hello")
print("how are you")
]]
  }


The way you have done it, the print statements are evaluated immediately, because they are evaluated at addxml.timer time, not when the timer fires.

- Nick Gammon

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

Posted by Shaun Biggs   USA  (644 posts)  [Biography] bio
Date Reply #3 on Fri 25 May 2007 09:07 AM (UTC)
Message
I tested that out, and it worked fine, but I didn't think that it was waiting the 5 seconds. I set second=59, and it still was firing within two seconds. Adding offset_second=59 to that as well still did not delay the printing more than 2 seconds. This is with MC 4.05

It is much easier to fight for one's ideals than to live up to them.
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #4 on Fri 25 May 2007 11:08 PM (UTC)
Message
You are right, there is a bug in ImportXML where it doesn't reset a new timer.

I will correct that in the next version.

Meanwhile, in your example, adding the line:


ResetTimer ("test1")


... after addxml.timer, will fix it.

What MUSHclient does, is reset all timers after loading a new world, so for a full load, timers will be reset. However when the ImportXML functionality was added, the need to reset individual timers was overlooked.

- 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.


15,747 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]