Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ General ➜ Ungrouped Timers/Triggers/Etc

Ungrouped Timers/Triggers/Etc

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


Posted by Xvordan   (29 posts)  Bio
Date Fri 27 Jun 2014 06:24 PM (UTC)
Message
I'm writing scripts for a mud I play, in which I make pretty judicious use of the DoAfter and DoAfterSpecial temporary timer creators. My problem is that, when I want to disable certain features, those temporary timers aren't, of course, automatically destroyed, and DeleteTimer/TimerGroup and its ilk won't let me use "" to referenced ungrouped or unlabled objects.

Is there anyway the Doafter and its similar DoAfterSpecial sibling could be made to support optional parameters after the duration and text to provide a label and a groupname? I know I could use AddTimer in place of DoAfter, but Doafter's just so convenient for temporary delays. Alternatively, is there a way to disable and/or delete such objects as have no group name or label?
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #1 on Fri 27 Jun 2014 08:41 PM (UTC)

Amended on Fri 27 Jun 2014 08:42 PM (UTC) by Nick Gammon

Message
You can find the unlabelled triggers/timers etc. like this:


tl = GetTimerList ()
if tl then
  for k, v in ipairs (tl) do 
    Note (v) 
  end  -- for
end -- if we have any timers


That lists all timers, and uses an internal name for unlabelled ones, eg.


pilot_timer
*timer247   <--- this one is unlabelled
runaway


Knowing that, you can now use GetTimerInfo to find out things like their name and group, eg.


tl = GetTimerList ()
if tl then
  for k, v in ipairs (tl) do 
    print ("internal name =", v)
    print ("external name =", GetTimerInfo (v, 22) )
    print ("group =", GetTimerInfo (v, 19) )
    print ""
  end  -- for
end -- if we have any timers


Output:


internal name = pilot_timer
external name = pilot_timer
group = 

internal name = *timer247   <--- internal name
external name =             <--- this one is unlabelled
group = foo                 <--- this one is in a group

internal name = runaway
external name = runaway
group = 


Now you can just use that information to enable or delete them.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #2 on Fri 27 Jun 2014 08:49 PM (UTC)
Message
Quote:

Is there anyway the Doafter and its similar DoAfterSpecial sibling could be made to support optional parameters after the duration and text to provide a label and a groupname?


You could do that yourself easily enough. Just write a function that looks similar to DoAfter which does what you want. After all, DoAfter is just a simplified interface to AddTimer with most parameters taking defaults.

Basically it adds a timer with:


  • Enabled = true
  • One-shot = true
  • Temporary = true
  • Active-when-closed = true
  • Send-to = as specified (eg. script, world, etc.)
  • At-time = "every x seconds" (not "at a time")
  • Time interval = as specified


You could write that in 5 minutes and call it MyDoAfter or something.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #3 on Fri 27 Jun 2014 09:01 PM (UTC)
Message
Also see: http://gammon.com.au/modules

Scroll down to the addxml.lua part.

You can add timers, triggers and aliases easily by just setting up a Lua table and then calling addxml.trigger (t) (or timer or alias) as required.

This lets you set up the group easily.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
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.


17,489 views.

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

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.