|
RexArcanus Newbie
Joined: 23 Jul 2004 Posts: 2
|
Posted: 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. |
|
|
|
Danlo Magician
Joined: 28 Nov 2003 Posts: 313 Location: Australia
|
Posted: 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 :) |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: 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. |
|
|
|
Danlo Magician
Joined: 28 Nov 2003 Posts: 313 Location: Australia
|
Posted: 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. |
|
|
|
RexArcanus Newbie
Joined: 23 Jul 2004 Posts: 2
|
Posted: Mon Jul 26, 2004 6:05 am |
Thanks for your help! It works like a charm.
|
|
|
|
|
|