Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.
 Entire forum ➜ MUSHclient ➜ General ➜ Triggers

Triggers

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Shadowfyr   USA  (1,788 posts)  Bio
Date Mon 14 Jan 2002 10:47 PM (UTC)
Message
In another post you suggested to Magnum the following:

^(> )*(\w*) Thanks you\.$

There may be two flaws in this, besides the fact that regular expressions remind me of Esoteric programming languages. (i.e. The most confusing way of doing something, while still producing functional code. lol) This is of course only an opinion. ;) The first is that it may be possible to trigger on something that does not happen any where near the prompt line. A good example in my case is that the mud me and Magnum both play on doesn't let you customize channel colors, so I use a trigger to seperate out traffic in those channels for [sales] and [newbie]. Most of the time they never end up on a prompt line. The same is often true of other things, so the '> ' or in my case ' ', must be an optional result. The above assumes that it always starts with '> ', which won't work. Of course if the dang mud didn't automatically add an extra space after the prompt, even when the last command was a newline this would be a null issue. lol The second problem is that really long tests like, 'Bauka lets his healing powers flow through the world.', I have had to shorten a bit, since Mushclient seems to choke on them when the string you want to match is too big. Or it has once or twice for me anyway, but I may have just messed up.

The second problem is not a big deal, but simple adds additional complications to making it match. The first problem is one that I have struggled with and gave up on when trying to use regular expressions, since it both 'must' match on the correct result, but the first few characters also 'must' be optional. Forcing it to only happen on prompts is just not parctical. So far my own attempt to find a expression that I can add to the beginning of a line that always works have failed, precisely for this reason.
Top

Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Reply #1 on Mon 14 Jan 2002 11:26 PM (UTC)
Message
Hmm, it should work. The sequence:


(> )*


should match OK, as it represents "zero or more" (the asterisk) of "> ".

Zero or more would handle the case of no prompt.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Krenath   USA  (76 posts)  Bio
Date Reply #2 on Tue 15 Jan 2002 12:02 AM (UTC)

Amended on Tue 15 Jan 2002 12:04 AM (UTC) by Krenath

Message
You could also try using

([> ]*) as the string to match the prompt.

This would match any combination of spaces and greather-than symbols in any order. If there are zero, two, three, five, or however many leading or trailing spaces or prompt symbols, it'll still match.

^([> ]*)(\w*) Thanks you\.$

Is 'Thanks you' capitalized in that way? You might try

[Tt]hanks you\.

- Krenath from
bDv TrekMUSH
ATS TrekMUSH
TNG TrekMUSE
TOS TrekMUSE
Top

Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Reply #3 on Tue 15 Jan 2002 12:38 AM (UTC)
Message
You can make caseless regular expression matching with an internal option. I quote from the supplied regular expression documentation file:


    The settings of PCRE_CASELESS, PCRE_MULTILINE,  PCRE_DOTALL,
     and  PCRE_EXTENDED can be changed from within the pattern by
     a sequence of Perl option letters enclosed between "(?"  and
     ")". The option letters are

       i  for PCRE_CASELESS
       m  for PCRE_MULTILINE
       s  for PCRE_DOTALL
       x  for PCRE_EXTENDED

     For example, (?im) sets caseless, multiline matching. It  is
     also possible to unset these options by preceding the letter
     with a hyphen, and a combined setting and unsetting such  as
     (?im-sx),  which sets PCRE_CASELESS and PCRE_MULTILINE while
     unsetting PCRE_DOTALL and PCRE_EXTENDED, is also  permitted.
     If  a  letter  appears both before and after the hyphen, the
     option is unset.


Thus, you could imbed "(?i)" to have caseless matching.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Shadowfyr   USA  (1,788 posts)  Bio
Date Reply #4 on Tue 15 Jan 2002 07:53 AM (UTC)
Message
What are PCRE_DOTALL and PCRE_EXTENDED?

Too bad there is nothing I can match on with channels at the end of the messages. Having a multiline option would solve the premanent line wrap problem AoD has when trying to color lines. :p

Anyway, will try to see if it works. Dang things can be a pain to get right. ;) At least they are not coded using something like http://www.p-nand-q.com/java2K.htm. And no, this is not really Java, but claims to have been created do to the fact that Java wasn't 'annoying enough' <- This is sort of paraphrased and sort of assumed base on the insane discription supplied for the languages implimentation. ;)
Top

Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Reply #5 on Tue 15 Jan 2002 09:18 PM (UTC)

Amended on Tue 15 Jan 2002 09:22 PM (UTC) by Nick Gammon

Message
From the documentation:


If the PCRE_DOTALL option is set, then dots match newlines as well.


However this will not apply as MUSHclient only sends single lines to the regular expression matching code.



WHITESPACE

If a pattern is compiled with the PCRE_EXTENDED option, whitespace in the pattern (other than in a character class) and characters between a "#" outside a character class and the next newline character are ignored. An escaping backslash can be used to include a whitespace or "#" character as part of the pattern.

COMMENTS

The sequence (?# marks the start of a comment which continues up to the next closing parenthesis. Nested parentheses are not permitted. The characters that make up a comment play no part in the pattern matching at all.

If the PCRE_EXTENDED option is set, an unescaped # character outside a character class introduces a comment that continues up to the next newline character in the pattern.


In other words, you can imbed spaces and comments. eg.


(?x)^ ([>\ ]*)   (\w*)\   Thanks\ you\ .$ # my comment 


In this example I have a comment after the "#" and multiple spaces between parts of the regular expression, for readability. However when I really want a space, it has to be "escaped" with a backslash.


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Magnum   Canada  (580 posts)  Bio
Date Reply #6 on Wed 16 Jan 2002 04:49 AM (UTC)
Message
I don't know what problem you are having shadowfyr, but the following DOES work for me:

^(> )*(\*)*(\w*) thanks you(.*?)

I've modified it slightly, to trigger on the emote being sent to me from a remote room. (It works whether the sender is local or remote).

^ -- Start of line
(> )* -- Zero or more instances of "> "
(\*)* -- Zero or more instances of "*"
(\w)* -- One word wildcard
(.*?) -- Open ended wilcard, since it's possible to send a message with thanks.

Similarly, I have many trigger lines that start with:

^(> )*

Here's my trigger for heal the world:

^(> )*(\w*) lets (.*?) healing powers flow through the world\.$

...and it works fine for me. I could probably edit the last wildcard to alse be (\w*) and it would still work, since it is accounting for "his\her". ...Heck I should probably make it (his|her) if I want to be as precise as possible.

LOL! There was a LONG pause as I participated in a drow invasion. :)

Regarding channel colours, have you tried "term configure" on AOD?

term configure
Okay, lets get some nice settings for your terms. All these settings will
be saved. If you want the [default] colour, you can just press return.
Valid VT100 modes are : bold, normal
Addition for ANSI we have : red,green,yellow,blue,magenta,cyan,white
or for high intensity : hred,hgreen,hyellow,hblue,hmagenta,hcyan,hwhite

Which colour would you like for other_spell messages [hblue] ?
Which colour would you like for mage_channels messages [magenta] ?
Which colour would you like for warrior_channels messages [magenta] ?
Which colour would you like for emote messages [blue] ?
Which colour would you like for shout messages [hred] ?
Which colour would you like for spouse messages [hmagenta] ?
Which colour would you like for gossip_channels messages [hmagenta] ?
Which colour would you like for announce messages [red] ?
Which colour would you like for rogue_channels messages [magenta] ?
Which colour would you like for tell messages [yellow] ?
Which colour would you like for say messages [hmagenta] ?
Which colour would you like for priest_channels messages [magenta] ?
Which colour would you like for sales_channels messages [magenta] ?
Which colour would you like for hp_bar messages [blue] ?
Which colour would you like for stun messages [hred] ?
Which colour would you like for combat messages [normal] ?
Which colour would you like for spell messages [green] ?
Which colour would you like for skill messages [hgreen] ?
Which colour would you like for party messages [green] ?
Which colour would you like for whisper messages [hmagenta] ?
Which colour would you like for song messages [hmagenta] ?
Which colour would you like for pk_channels messages [magenta] ?
Which colour would you like for short_desc messages [blue] ?
Which colour would you like for critical_hit messages [hred] ?
Which colour would you like for breaks messages [hred] ?
Which colour would you like for other_song messages [hblue] ?
Which colour would you like for other_skill messages [hblue] ?

Configuration finished.

Get my plugins here: http://www.magnumsworld.com/muds/

Constantly proving I don't know what I am doing...
Magnum.
Top

Posted by Shadowfyr   USA  (1,788 posts)  Bio
Date Reply #7 on Wed 16 Jan 2002 09:49 PM (UTC)
Message
You got into an invasion?... Dang, missed another one, though Drow and Shadows usually mean ,'Run away very fast and hide in my house.' for me. ;) lol

Hmm. Been a while since I checked on the configuration, a few months ago you couldn't configure a lot of those.

The thing is I prefer custom colors though. While I don't really care if BS, DR, HE, CLE and GOSSIP are all the same color (would be nice if they could be different, but not enough custom colors), I definitely want SALES an NEWBIE to stand out. Not that most of the time I can type fast enough to respond on newbie before someone else does... lol Making sales Magenta is ok, but I also like it to be a little different color from EVENTS, so I can ignore anything that might be going on there, but still notice SALES immediately. Same with a lot of other things, the basic 16 colors just don't provide enough differences to customize things the way I want and having only 16 custom colors (some of which I left the same as the ansi, since I color my combat results as well), is only barely enough for what I have customized. And as you no doubt have noticed, neither NEWBIE nor the 'you hit', 'they hit' stuff in combat is currently customizable. :p

In any case, the mear fact that with AoD you can't turn off line wrap, so the client can handle it, and the fact that it ignores width settings over the preset wrapping, even if you use the term configure to explicitly tell it you have a wider window, makes doing some things impossible.

It is not really a problem since I am used to it, but it would be nice if it didn't force some of these things on you.

As to the stuff I customed using mush, to give you an idea of the problem I have with Term Configure:
NEWBIE - Sort of a dark Blue-Grey
SALES - Hot Pink
mod doesn't hit me - Dark Green
Most hits on me - Red
Really big hits on me - Orange
Depositing/tranferring coins - Ansi Light Blue
*'s party - very light Blue
HP status (from sacred guardian) - Orange
HP status (mine) - very light Blue
Someone entering the game - Light Green
My spell effects - Dusty orange (starting to grey)
My hits - Light green
*poison* - Olive Green
Item breaks - Orange

Probably missing a few, since I am using all 16 custom colors to do these things...

All but sales in this list are non-customizable from the mud and even if they where I would be stuck with only the ansi colors. Though being able to customize combat from the ugly grey would free up at least 2 custom colors. ;)
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


19,505 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.