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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Ashur
Novice


Joined: 25 Jul 2011
Posts: 39

PostPosted: Sun Oct 23, 2011 11:01 pm   

Background status checking
 
In essence, I would like to create a background query that alerts me when the results of my query change. I would like it so that this query ran without causing any input or output to be displayed to the user (me). I'm guessing that portion should be possible with clever usage of #GAG. Here is what I'm looking to do:

The command 'mlist' returns a list of the currently signed on players of my guild, with a predicable beginning and end (should make capturing the list easy). Looks something like this:

Code:
The members of the Society of Morgul Mages currently in the realms:
: <name>
: <name>
There are now three Morgul Mages serving the Dark Lord.

The names are presented without the "< >" of course.

I'd like if the 'mlist' command could be automatically be sent every 'n' seconds. Then store the returned list of users in a variable and compare it to the last 'mlist' result. If the list has changed, I would like the original 'mlist' query to stop and, instead, start a new trigger that will notify me every 'y' seconds that the list has changed. The alert will cease after the command 'mlist' is returned and the original query will being running again.

Some of this I know how to do, the thing I need the most help with is the making it not display every time it runs and saving the list in a meaningful manner in a variable.

Can anyone help? It would be greatly appreciated.
Reply with quote
Fizgar
Magician


Joined: 07 Feb 2002
Posts: 333
Location: Central Virginia

PostPosted: Mon Oct 24, 2011 1:29 am   
 
Here is one possible way to do it, going by the information you supplied and manual show's to imitate the mud response. I'll be glad to answer any questions you have IF it works for you.

Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <class name="MlistClass" copy="yes">
    <trigger name="MlistCheck" type="Alarm" priority="6110" enabled="false" copy="yes">
      <pattern>30</pattern>
      <value>mlist</value>
      <trigger>
        <pattern>^The members of the Society of Morgul Mages currently in the realms:</pattern>
        <value>#gag
MlistNew = ""</value>
      </trigger>
      <trigger type="Manual">
        <pattern>(*)</pattern>
        <value>#if (%match(%1,"^:%s(*)",$name)) {
  #gag
  #additem MlistNew $name
  } {
  #gag
  #state 3
  }</value>
      </trigger>
      <trigger type="Alarm">
        <pattern>1</pattern>
        <value>#gag

#forall @mlistNew {
  #if (%ismember(%i,@MlistOld)) {} {#t+ notification;#t- MlistCheck;#call %alarm(notification,1);MlistOld = @MlistNew}
  }</value>
      </trigger>
    </trigger>
    <var name="MlistNew" type="StringList" copy="yes">
      <value>bob|jim</value>
      <json>["bob","jim"]</json>
    </var>
    <var name="MlistOld" type="StringList" copy="yes">
      <value>bob|jim</value>
      <json>["bob","jim"]</json>
    </var>
    <alias name="mlist" copy="yes">
      <value>MlistOld = ""
#t+ MlistCheck
#sendraw mlist
#t- notification</value>
    </alias>
    <trigger name="notification" type="Alarm" priority="110" copy="yes">
      <pattern>10</pattern>
      <value>#print Type mlist to disable notification.</value>
    </trigger>
  </class>
</cmud>
_________________
Windows Vista Home Premium SP2 32-bit
AMD Athlon Dual Core 4400+ 2.31 GHz
3 GB RAM
CMUD 3.34
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD 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