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.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ Suggestions
➜ Triggers
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Matthias
(28 posts) Bio
|
Date
| Mon 08 Sep 2003 03:02 AM (UTC) |
Message
| I think there should be a sort of Mass trigger entering system, like:
If you match any of these:
You feel your muscles lock up.
You cannot do that, you are paralyzed.
Your muscles stiffen up.
Then enter:
eat bloodroot |
Give a man a fire and you warm him for a day.
Set a man on fire and you warm him for the rest of his life. | Top |
|
Posted by
| Ked
Russia (524 posts) Bio
|
Date
| Reply #1 on Mon 08 Sep 2003 03:17 AM (UTC) |
Message
| You can do just that with regular expressions:
^(You feel your muscles lock up\.|You cannot do that, you are paralyzed\.|Your muscles stiffen up\.)$
That'll make a trigger which will match on any of the options in parenthesis. There's a file named RegularExpressions.txt in your Mushclient/Docs directory that explains the syntax and general rules of using regular expressions. But in brief the meaning of the above is:
^ - denotes the start of line
$ - denotes the end of line
\ - an escape character, it's needed in this case because '.' means any character in RegExp
() - denote what should be captured as a wildcard, and serve for grouping
| - a "switch", ^(a|b)$ will match on either 'a' or 'b' but not on 'ab'. | Top |
|
Posted by
| Matthias
(28 posts) Bio
|
Date
| Reply #2 on Fri 12 Sep 2003 09:26 PM (UTC) |
Message
| So if I wanted to put a wildcard in there, would I just put the normal * for that? or is it different for the Regular expression thing? (whatever that is) |
Give a man a fire and you warm him for a day.
Set a man on fire and you warm him for the rest of his life. | Top |
|
Posted by
| Flannel
USA (1,230 posts) Bio
|
Date
| Reply #3 on Fri 12 Sep 2003 09:30 PM (UTC) |
Message
| in a reg exp, a * is 1 or more of the previous character, so a * in a normal trigger becomes a .* in a reg exp (. being the wildcard character)
Can read about it in the VB/Java (windows script) Documentation, links are on the top of the forum |
~Flannel
Messiah of Rose
Eternity's Trials.
Clones are people two. | Top |
|
Posted by
| Matthias
(28 posts) Bio
|
Date
| Reply #4 on Wed 17 Sep 2003 02:42 AM (UTC) |
Message
| So, is an escape character used to indicate not to interpret a symbol as a reg exp? So for a wildcard, I'd do something like this:
^(/* brings /* arms crashing down on you/.)$
, right? |
Give a man a fire and you warm him for a day.
Set a man on fire and you warm him for the rest of his life. | Top |
|
Posted by
| Flannel
USA (1,230 posts) Bio
|
Date
| Reply #5 on Wed 17 Sep 2003 06:36 AM (UTC) |
Message
| Well, if you switched the slashes to backslashes...
That would match on the line....
* brings * arms crashing down on you.
But, if you want something infront of the asterix (which arent variables, just the asterix) youd need to either get rid of the ^ (start of the line) OR add a .* in between the ^ and the \*
Also, if you wanted the parenthesis to be included, you would need to escape them. |
~Flannel
Messiah of Rose
Eternity's Trials.
Clones are people two. | Top |
|
Posted by
| Nick Gammon
Australia (23,140 posts) Bio
Forum Administrator |
Date
| Reply #6 on Thu 18 Sep 2003 06:46 AM (UTC) |
Message
| Try entering this in a trigger:
* brings * arms crashing down on you.
And then click on "convert to reg. expression" - that will show the differences. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Matthias
(28 posts) Bio
|
Date
| Reply #7 on Mon 22 Sep 2003 09:20 PM (UTC) |
Message
| Umm, I'm not really sure what I'm doing wrong... I have the trigger set to match this...:
^(\*You have a particularly intense shiver\*|\*maw and exhales a blast of frigidly cold air on you\*|\*You feel the strength ebb from your body as the cold takes its toll\*|\*raises a hand towards you and blasts you with cold, frigid air\*|\*Your body slows as it freezes in the extreme cold\*|\*sends the cold of the grave\*|\*The bubonis entity sinks its teeth into you, and begin shivering\*)$
And to send this:
apply caloric
But it won't match... what am I doing wrong? (That matching above was one of the shorter ones :p) |
Give a man a fire and you warm him for a day.
Set a man on fire and you warm him for the rest of his life. | Top |
|
Posted by
| Ked
Russia (524 posts) Bio
|
Date
| Reply #8 on Tue 23 Sep 2003 03:04 AM (UTC) |
Message
| You seem to be still confused about the wildcards in regexp's. Here, by doing '\*' you are actually telling the client to match on, for example:
*You have a particularly intense shiver*
this is the literal string that your trigger will match on. It won't match on something like:
3245h, 1256m cexkdb-You have a particularly intense shiver.
The reason for this is that you are using an escape character ('\') before an asterix, which itself is a special character denoting any number of whatever precedes it. However, when escaped with '\' any special character is interpreted literally. So to cut the long story short, in order to match on:
3245h, 1256m cexkdb-You have a particularly intense shiver.
you'd need to use wildcards, and a basic wildcard in regexp is denoted by '.' (period). There are other types of wildcards but this one works in all cases. The most basic form of a wildcard in regexp looks like:
which tells the client to match on any number of anything.
Thus, you could amend your trigger to include:
.*You have a particularly intense shiver.*
To reiterrate on the meaning of the escape character using the above example - if you actually wanted to include the period at the end of the above line (the actual period in the end of the sentance), instead of a wildcard that would match that period among other things, you would do:
.*You have a particularly intense shiver\.
By prepending an escape character to a special wildcard character '.' you are stripping any "specialness" off the latter and turn it into a simple literal, just like any letter in the string >You have a particularly intense shiver". Hope that makes sense. As Nick suggested, one of the best ways to figure out the basic regexp syntax is to use Mushclient's 'Convert to regular expression' option in the Add Trigger dialogue, that will take your trigger (normal one, without any special syntax, like "*You have a particularly intense shiver*") and turn it into a corresponding regexp, showing you how the syntax works. Although that provides only the minimum functionality of regexp, it can be very useful when just starting out.
| 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.
20,806 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top