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


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Tips and tricks
. . -> [Subject]  How to remove all timers, or remove one timer.

How to remove all timers, or remove one timer.

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


Posted by Jlake   (4 posts)  [Biography] bio
Date Mon 01 Apr 2002 11:54 AM (UTC)
Message
After addtimer,I want to remove it after some time.
How to do this?
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Mon 01 Apr 2002 10:20 PM (UTC)
Message
There are a few ways you can do this. You haven't said how you would define "after some time" but I'll give various methods ...


  1. The simplest is to make a one-shot timer. This will fire once and then delete itself. This is handy if you only want to do something once, but in the future (eg. in 5 minutes).


  2. Next, you could make two timers, one which deletes the second one, like this:


    World.addtimer "my_timer", 0, 0, 20, "drink water", 1, ""
    World.addtimer "delete_my_timer", 0, 5, 0, "", 5, "delete_timer"


    The first timer (my_timer) fires every 20 seconds, and sends "drink water" to the MUD.

    The second timer (delete_my_timer) fires after 5 minutes, and is a one-shot timer (hence the flag of 5). It calls a script delete_timer.

    The script delete_timer would look like this:


    sub delete_timer (timer_name)
    world.deletetimer "my_timer"
    end sub




  3. You could use a trigger or alias to delete the timer. A trigger might be used if you wanted to do it automatically when something happened, an alias if you wanted to do it yourself.

    In each case they would call a script like this:


    sub OnDeleteTimer (strName, strLine, aryWildcards)
    world.deletetimer "my_timer"
    end sub



  4. If you have lots of such timers it gets slightly more complicated because then you need a way of knowing which timer to delete. I would then use a variable to remember which timer to delete.

- Nick Gammon

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

Posted by Jlake   (4 posts)  [Biography] bio
Date Reply #2 on Tue 02 Apr 2002 12:18 AM (UTC)
Message
Thanks a lot.
[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.


10,482 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]