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
RexArcanus
Newbie


Joined: 23 Jul 2004
Posts: 2

PostPosted: Sun Jul 25, 2004 2:46 pm   

A request for help with a multi-line filter
 
Hi! I've been playing around with zMUD for awhile now, nothing too serious, coding sets of triggers. I've come across a something that I can't get to work, and I am wondering if someone could help me out.

Basically, there are about 15 phrases that a mud sends to me again and again. I really don't care about them, and have them #GAG'ed. Now what I'd like to do is have a block of code (for instance a #BEEP) go off when something that isn't one of these 15 phrases happens.

I tried something like:
#TRIGGER {^(*)$} {#IF (%1 =~ "Phrase 1") {#GAG} {#IF (%1 =~ "Phrase 2") {#GAG} {#BEEP}}}

But it both didn't work and looked like it would get pretty ugly as the number of phrases increased.

Any suggestions would be helpful.
Reply with quote
Danlo
Magician


Joined: 28 Nov 2003
Posts: 313
Location: Australia

PostPosted: Sun Jul 25, 2004 5:44 pm   
 
#trigger {*{^@GaggedPhrases}} {#beep}

What this trigger does is looks for any line not containing any of the phrases which are contained in the GaggedPhrases ariable, and emits a beep. You're likely to get a lot of beeps though, unless you mostly only get the phrases :)
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Sun Jul 25, 2004 8:11 pm   
 
As always, use GROUPING characters (such as double-quotes) if you expect %1 to ever be more than one word.
Starting *'s match everything from the beginning of the line and ending *'s match everything until the end of the line, so the anchors (^ and $) aren't needed in the pattern.
You can use the string-list wildcard with a list-variable, {@GaggedPhrases}, to simplify your #IF.
#ADDI GaggedPhrases {Phrase 1}
#ADDI GaggedPhrases {Phrase 2}
#TR {(*)} {#IF ("%1" =~ {@GaggedPhrases}) {#GAG} {#BEEP}}

Danlo:
I don't think you can use list-variables (or any variables) in the excluded string wildcard, {^string}. Everything after the ^ is treated as a literal character.
_________________
LightBulb
Senior member

Most scripts in this forum are written for Command Line entry.
Don't even open the Settings Editor unless its use is specified or obvious.
Reply with quote
Danlo
Magician


Joined: 28 Nov 2003
Posts: 313
Location: Australia

PostPosted: Sun Jul 25, 2004 8:34 pm   
 
Its always worked for me, Lightbulb, no worries.
The only thing I've noticed, is that something else is required to be in the Pattern aside from the excluded stringlist. Usually, I just surround it by () if its an exact line I don't want matched.
Reply with quote
RexArcanus
Newbie


Joined: 23 Jul 2004
Posts: 2

PostPosted: Mon Jul 26, 2004 6:05 am   
 
Thanks for your help! It works like a charm.
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