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