Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
kaupmat
Newbie


Joined: 13 Jan 2009
Posts: 4
Location: Helsinki

PostPosted: Sun Mar 26, 2023 11:45 am   

Trigger to disconnect NOW and reconnect after specific hours
 
How can I trigger disconnect now, and then reconnect with xx hours! from ..

xxx tells you re-connect xx hours

I am guessing I should use
#con #disconnect and #alarm triggers here!

Thanks :)
Reply with quote
mikeC130
Apprentice


Joined: 03 Jul 2006
Posts: 108

PostPosted: Sun Mar 26, 2023 3:20 pm   
 
The following trigger will meet your basic requirements.
Code:
<trigger priority="220" id="22">
  <pattern>* tells you re-connect (%d) hours.</pattern>
  <value>$timer = %1
time = $timer * 3600 // 3600 seconds in an hour so this gives alarm in seconds
#DISCONNECT
#ALARM reconnect {+@time} {#CONNECT}
</value>
</trigger>

This will match on any name, but will need an integer for the number of hours (1, 2, 6, etc., but not 1.5). Upon a match, it captures the length of time in hours in the local varialbe $timer, and then converts to seconds and saves in a regular variable @time. You can use a local variable for this if you want as well. It then disconnects and creates an alarm called reconnect that will fire after that amount of elapsed time and execute the #connect command. The alarm will be deleted once it executes the command.

You will likely need to make some adjustments, however. First, I expect you will want to modify the trigger pattern to match the specific text your mud sends in case of a tell. You could put a ^ at the start of the pattern to ensure that this only occurs at the start of a line, for instance. Secondly, you may well want to filter the input such that you don't disconnect just because somebody that you've never heard of tells you to disconnect. So you may want to create a stringlist with the names of such characters that you want to allow this and use that in place of the * in the pattern. This could be a stringlist or you could enter it manually into the pattern, such as {Bill|Bob|Frank} tells you... This will match the pattern without capturing it. If you have a variable @names with these names in it, your pattern would be {@names} tells you...

Mike

edit - I just realized that you posted this in the zMUD forum rather than CMUD. For zMUD you'll have to change the local variable $timer to a normal variable, since zmud does not have local variables. In that case eliminate the $ in the first line of the actual script where timer is assigned to the value from %1, and on the next line replace $timer with @timer. I believe that it should work with just those changes - and would work in CMUD as well.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net