timer fires right away when enabled

Posted by Shwick on Sun 30 May 2010 07:08 AM — 4 posts, 19,175 views.

#0
I have a timer already created in my plugin with xml, and when I enable it in my script it fires immediately.

How can I make it fire after 15 seconds when enabled?


<timer name="rootNodeTimer" script="rootNodeTimerScript" second="15.00" offset_second="0.00" >
</timer>


I tried changing offset to 15, also tried seconds to 30 and offset to 15.

Amended on Sun 30 May 2010 07:46 AM by Shwick
Australia Forum Administrator #1
Reset the timer immediately after enabling it. Otherwise it will have passed its fire time some time back.

Template:function=ResetTimer
ResetTimer

The documentation for the ResetTimer script function is available online. It is also in the MUSHclient help file.


#2
k thanks that works for me

what exactly does the timer offset do, i haven't seen it clearly defined anywhere
Australia Forum Administrator #3
Say you wanted to do this:


sing 
(wait 10 seconds)
dance
(wait 10 seconds)
laugh
(wait 10 seconds)
sing 
(wait 10 seconds)
dance
(wait 10 seconds)
laugh
(wait 10 seconds)


... and repeat that.

Now you sing every 30 seconds (ditto for dance and laugh) but if you put them all on a 30-second timer, you would get:


sing / dance / laugh
(wait 30 seconds)


To fix this you have them all on 30-second timers, but dance has a 10-second offset, and laugh has a 20-second offset.

Effectively the offset is the distance "into" the timer interval that the timer fires.