Issue with enable/disable timers

Posted by Stoned00d on Wed 24 Apr 2002 08:36 PM — 7 posts, 29,550 views.

#0
Whenever you use a script to disable a trigger and then enable the same one again, the trigger goes off right away instead of waiting the timer time. I believe I tried including an offset and getting the same results. Is there anyway to make it wait a full cycle?
Australia Forum Administrator #1
Your problem is that the timer has elapsed, however it is disabled. When you enable it, it fires soon after. What you need to do is also "reset" it, which makes it start counting again.

eg.


World.EnableTimer "mytimer", vbTrue
World.ResetTimer "mytimer"


Post amended on 25/Nov/2002 to reverse the order of the above two statements.
Amended on Sun 24 Nov 2002 07:29 PM by Nick Gammon
#2
Just a general question: is there a website that has a list of all the commands that are included in VBscript? Microsoft has a very nice page expalaining all the built in functions, but MUSH also includes a lot of world.(something) commands that aren't included.
Australia Forum Administrator #3
They are all documented at MUSHclient scripting functions - complete with examples in VBscript, Jscript and Perlscript.
#4
Either I am doing something wrong with resetting timers or something is broke in 3.32 with the following:

Timer set up to fire every 10 seconds. Here's the XML from the world file.
<timer name="tmrTest" script="TestTimer" second="10" >
</timer>


Here's the underlying code:

Sub timerTest
World.note "--- Setting timer --- (" & Now & ")"
World.ResetTimer "tmrTest"
World.EnableTimer "tmrTest", TRUE
End Sub

Sub TestTimer(a)
World.Note "Test timer fired. (" & Now & ")"
World.EnableTimer "tmrTest", FALSE
End Sub

If I call timerTest from the command ("/timerTest") or from a script, the Timer still fires off immediately. If I just enable it from the GUI, it takes 10 seconds.

Thanks!
Australia Forum Administrator #5
It seems my earlier post was wrong. Looking at the code MUSHclient does not reset timers that are disabled. Thus you need to enable it first, and then immediately reset it.

I have corrected the earlier post in case people read that and don't read on to the correction. The correct way is:


World.EnableTimer "mytimer", vbTrue
World.ResetTimer "mytimer"
#6
Thanks Nick! This is why I was happy to register, you are always very responsive and supportive.

As you noted, doing a TimerEnable and then immediately doing a TimerReset does the trick. My thanks!

Regards,
Neurowiz