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
elektrisk
Novice


Joined: 06 May 2008
Posts: 38

PostPosted: Tue Nov 04, 2008 8:38 am   

How would I make this kind of script?
 
Ok, I want a script that says on a certain channel (clan channel) what zone respawned when it does. On the mud I play, there's a world echo for when one respawns:
You hear a faint rumble off in the distance.

There's a command to check which zones are up and which are down, which is 'zones'. This is what it says when a zone is up (I picked a random zone):
Code:
[The Monastery of Devenon                ][     ZONE UP]


This is what it says when one is down:
Code:
[The Lost Ship of the Ouset People       ][   ZONE DOWN]


I assume I'd need to make variables for each zone, and set it so that when it shows a respawn message, I "zones", and if the status has changed, I change the variable, but could anyone tell me step by step how to do this?

If I have left out any vital information, please tell me.

Thanks.
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Tue Nov 04, 2008 12:27 pm   
 
I'm confused. Your game already does this, or you want to make a command that lists the zones and whether or not they are up or down?
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Tue Nov 04, 2008 1:48 pm   
 
Hmm... lets try this. You need some kind of pattern that tells you when the list of zones has finished - whatever line immediately follows that list. It'll probably be your prompt or a blank line, but you didn't say.

#oninput {zones} {OldZones=@Zones;Zones="";#t+ ZoneCap}
#cond {whatever line ends your zone list here} {#t- ZoneCap;PrintZones}

#trig "ZoneCap" {[(.+?)\s+][\s+ZONE (\w+)]} {#addkey Zones %1 %2} "" {regex|disable}

#alias PrintZones {#loopdb @Zones {#if (%val != %db(@OldZones,%key)) {clantell Zone %key is now %val}}}

The basic principle of this script is that the ZoneCap trigger stores the status of the zones in a variable. When you do the zones command again, the zones oninput trigger stores the old contents of the variable and looks at the status again. You now have an old version and a new version, which you can then run through and compare to see what's changed. The PrintZones alias does that final step. All you need to do to make this script work automatically is a simple

#trig {You hear a faint rumble off in the distance.} {zones}

PS. Sorry I had to use a regex for the ZoneCap trigger, I hope it's not too confusing. I wanted the non-greedy capture so that it didn't capture all the spaces at the end of the zone name.

PPS. You might spam your clan out with status updates the first time you run the zones command. You might want to remove the PrintZones alias from the trigger the first time you run it, or give them some forewarning.

Here's the XML for the above:

Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <class name="ZoneCap" copy="yes">
    <trigger type="Command Input" priority="10" trigontrig="false" copy="yes">
      <pattern>zones</pattern>
      <value>OldZones=@Zones;Zones="";#t+ ZoneCap</value>
      <trigger>
        <pattern>whatever line ends your zone list here</pattern>
        <value>#t- ZoneCap;PrintZones</value>
      </trigger>
    </trigger>
    <trigger name="ZoneCap" priority="30" regex="true" copy="yes">
      <pattern>\[(.+?)\s+\]\[\s+ZONE (\w+)\]</pattern>
      <value>#addkey Zones %1 %2</value>
    </trigger>
    <alias name="PrintZones" copy="yes">
      <value>#loopdb @Zones {#if (%val != %db(@OldZones,%key)) {clantell Zone %key is now %val}}</value>
    </alias>
    <var name="OldZones" copy="yes">The Monastery of Devenon=DOWN|The Lost Ship of the Ouset People=DOWN</var>
    <var name="Zones" type="Record" copy="yes">The Monastery of Devenon=DOWN|The Lost Ship of the Ouset People=UP</var>
  </class>
</cmud>
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
elektrisk
Novice


Joined: 06 May 2008
Posts: 38

PostPosted: Tue Nov 04, 2008 10:42 pm   
 
chamenas wrote:
I'm confused. Your game already does this, or you want to make a command that lists the zones and whether or not they are up or down?


No, the game gechos a message that lets players know that a zone respawned, but it doesn't show which. I want to make a script so that it tells my clanmembers what zone respawned, to save them the trouble in looking through all the zones on the "zones" menu.

Thanks a lot Fang! Just a few more questions. I want it to say on CLAN "RESAPWN: Zonename."
Also, I've never gotten that far into zMUD scripting, and I don't know how to use XML scripting. Could you tell me how to add all of the zones to that script? Thanks.

EDIT: I tried entering that XML into a new class, and it gave me the error:
File: . Line 3 Col: 1 Error: There is invalid data after valid XML document.

EDITEDIT: I tried entering it with the zScript above, and it did go through, and it responds to the finishing line after 'zones, but the MUD acts as though I entered an invalid command (it says: Huh!?!), so the alias was probably not made, because parsing is on.

Under the alias PrintZones, the code is:

Code:
#loopdb @Zones {#if (%val != %db(@OldZones,%key)) {house Zone %key is now %val}}


The problem, I think, is that something keeps disabling the class ZoneCap, which contains the variables and alias, ect. Do you know what could be doing this?


Last edited by elektrisk on Tue Nov 04, 2008 11:51 pm; edited 1 time in total
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Tue Nov 04, 2008 11:48 pm   
 
Just copy the XML text above, open the package editor and press Ctrl+V. The new ZoneCap class will appear. Then just type ZONES once yourself into the MUD to get it set up, and you're finished.

Not too difficult to do that, just change the if to

#if (%val = "UP" and %db(@OldZones,%key) = "DOWN") {clantell Respawn: %key}

If you really can't follow what it's doing, I'll be happy to provide more explanation; just point me at the part or parts that're causing you trouble.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Wed Nov 05, 2008 12:00 am   
 
Sorry Elek, I would have helped if I understood. Fiang is better though anyways :P
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
elektrisk
Novice


Joined: 06 May 2008
Posts: 38

PostPosted: Wed Nov 05, 2008 12:05 am   
 
Okay, it works, but the problem is when it rumbles ect and I check 'zones', it houses all of the zones, and I just want it to house which one has respawned, which would mean checking the variables to see which changed. It'd probably help me if I knew what both variables, OldZones and Zones, did. On the 'Zones' variable, it has all of the zones and their current conditions. (up or down). On the 'OldZones' variable, it has only the two zones that I provided in my first post: Devenon & Ouset.
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Wed Nov 05, 2008 12:09 am   
 
Sounds like you need an index variable with a true/false list that flicks on or off on update.
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Wed Nov 05, 2008 1:17 am   
 
The @OldZones variable stores the value of the @Zones variable when you do the command zones. So if you type zones again, the current value of @Zones will be put into @OldZones. You can see it doing that on the line OldZones=@Zones. The variable @Zones is then given the new values, from the text that's just appeared. Then the two sets of values (this time you did ZONES and the previous time you did ZONES) are compared, and zones that've gone from down to up are reported.

In short, @OldZones has that value because @Zones had that value when you imported the script. Do ZONES again and the list of zones that's currently in @Zones will be moved to @OldZones, and the script will work correctly. Obviously I couldn't prime the script with a full list of zones for you because I didn't know what a full list of zones was.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
elektrisk
Novice


Joined: 06 May 2008
Posts: 38

PostPosted: Wed Nov 05, 2008 2:35 am   
 
Fang Xianfu wrote:
The @OldZones variable stores the value of the @Zones variable when you do the command zones. So if you type zones again, the current value of @Zones will be put into @OldZones. You can see it doing that on the line OldZones=@Zones. The variable @Zones is then given the new values, from the text that's just appeared. Then the two sets of values (this time you did ZONES and the previous time you did ZONES) are compared, and zones that've gone from down to up are reported.

In short, @OldZones has that value because @Zones had that value when you imported the script. Do ZONES again and the list of zones that's currently in @Zones will be moved to @OldZones, and the script will work correctly. Obviously I couldn't prime the script with a full list of zones for you because I didn't know what a full list of zones was.


It works! Thanks so much everyone for your help! :) Sorry for all of my noobish questions :)
Reply with quote
elektrisk
Novice


Joined: 06 May 2008
Posts: 38

PostPosted: Wed Nov 05, 2008 7:09 am   
 
Ack, ran into another problem. Is there any way so that I can make it so it only clantells when the zone respawns? 'Cause now it says when the zone respawns and all, but also if a zone has depopped since the last rumble, and that can be really spammy after reboots, where all the zones are up, ect.

Thanks
Reply with quote
mr_kent
Enchanter


Joined: 10 Oct 2000
Posts: 698

PostPosted: Wed Nov 05, 2008 8:39 am   
 
This trigger causes the zones command to be sent to the mud whenever CMUD receives the rumble message:
Quote:
#trig {You hear a faint rumble off in the distance.} {zones}


As a guess, this message is also received when a zone is depopped and after a reboot.

Is there a specific line that you receive when you DON'T want to automatically send the zones command?
ie. "Stand by for reboot...." or "Reboot successful!" or "Nothing lives in The Monastery of Devenon!"

If so, another #Condition could be added to the rumble trigger to only send the 'zones' command at respawn.
Reply with quote
elektrisk
Novice


Joined: 06 May 2008
Posts: 38

PostPosted: Wed Nov 05, 2008 10:05 am   
 
Well, there's no message for when a zone depops. The problem is, when a reboot occurs, all of the zones are UP, but when another rumble happens, it clantells all of the zones that have depopped since the reboot happened. For instance, I was doing a 3 hour long run today after a reboot, and it rumbled 1.5hours in, and approximately 7 zones depopped since then, so it clan'd the 7 zones "ZONENAME is now DOWN!", but I don't want it to show when zones are down at all, all I care about is it showing a message when a zone has respawned and which one it was that respawned. So in actuality, the script does what it should, but the fact that it shows when zones are down is real frustrating.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Wed Nov 05, 2008 2:48 pm   
 
I posted about this above. Change the #if command in the PrintZones alias to

#if (%val = "UP" and %db(@OldZones,%key) = "DOWN") {clantell Respawn: %key}

This way it explicitly checks for zones that were down last time and are up this time, which is what you asked for.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
elektrisk
Novice


Joined: 06 May 2008
Posts: 38

PostPosted: Sat Nov 08, 2008 12:38 pm   
 
Thanks!
Reply with quote
elektrisk
Novice


Joined: 06 May 2008
Posts: 38

PostPosted: Mon Dec 01, 2008 8:25 am   
 
Sorry to bother y'all again, but is there a way I could set the script so that I could just type "zones" to update the variables. Sometimes I idle out and zones will pop while I'm not online, and when I log on and a zone pops, it says four zones pop when only one did because my variables weren't up to date. Right now, the script only fires if that "You hear a faint rumble off in the distance." fires.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Mon Dec 01, 2008 12:18 pm   
 
Yes - just do so. The script runs no matter the source of the "zones" command - it works whether you manually enter it or if the script enters it.

If you want it to update silently (so it'll update the variables but not print any changes - so you can do that once when you first log on to get the current state of the zones, and then every update after that will announce changes) I suggest creating an alias that does:

#alias SilentZones {SilentZones=1;zones}

And then changing the #t- ZoneCap;PrintZones trigger to

#t- ZoneCap;#if (!@SilentZones) {PrintZones};SilentZones=0

Then, when you use the SilentZones alias to cause a zonecheck, a variable is set that stops the PrintZones alias from being run - the variables will update, but nothing is output at the end.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
elektrisk
Novice


Joined: 06 May 2008
Posts: 38

PostPosted: Tue Dec 02, 2008 4:35 am   
 
Thanks a lot :D
Reply with quote
elektrisk
Novice


Joined: 06 May 2008
Posts: 38

PostPosted: Sat Dec 13, 2008 8:49 pm   
 
Ok, I had to reinstall cMUD and forgot to grab this script when I was backing up my triggers and such, and I tried re-entering the information as I did before, but for some reason, cMUD isn't storing the zones' statuses in the 2 variables. When I looked at the variable in the package editor for the first time, I saw all the zones and such for a split second then the variable went blank, and the OldZones variable keeps turning from Database to an AutoType variable. The Zones variable remains a database variable as it should, but is not storing any information. Any idea how to fix this?
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