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
➜ General
➜ A Macro and a Trigger: Both have similar patterns
|
A Macro and a Trigger: Both have similar patterns
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Smoothfonzo
(10 posts) Bio
|
| Date
| Thu 24 Jul 2008 06:53 PM (UTC) |
| Message
| Hey Nick, I've wanted to say, thank you so very much for Mushclient. It's a fantastic program. In the past, I've used Zmud, but over time, I had found it to be slower and slower, because it tried to do too many things. Older versions were OK, but newer ones were quite the hog.
Anyhow, my problem. I've read through the Regular Expressions, and I can't quite figure out what I need to do. In DuneMud, when I attack something, it shows up as:
You attack Mother.
Mother being the variable. I have this set as a trigger:
You attack (.*)
This fires off a whole round of commands, and is considered my vital trigger. It's used by typing "kill".
Now, there's an actual command on the Mud called attack, which I've set as a Macro, and has a similar line as the one above. For example:
You attack Mother's right hand, doing FATAL damage!
Mother, right hand, and FATAL are all variables.
The heart of the problem now. You can probably see where this is heading. Whenever I use my attack Macro, this also sets off my trigger containing my series of commands, when I'd already started a battle. I don't want this to happen.
How can I set up my triggers to not fire if I use my Attack macro? I would be grateful for any light that you can share. Thank you.
| | Top |
|
| Posted by
| David Haley
USA (3,881 posts) Bio
|
| Date
| Reply #1 on Thu 24 Jul 2008 07:29 PM (UTC) |
| Message
| You could try:
You attack (\w+)
instead. This will match just word characters instead of any characters, meaning that it will stop at the period or the apostrophe.
(You might need to set it in regex mode for this to work.) |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | | Top |
|
| Posted by
| Smoothfonzo
(10 posts) Bio
|
| Date
| Reply #2 on Thu 24 Jul 2008 08:00 PM (UTC) |
| Message
| | And how would I do that exactly? Do I simple use the checkbox in the trigger dialogue? I'm not quite sure where I'm supposed to place (\w+). | | Top |
|
| Posted by
| David Haley
USA (3,881 posts) Bio
|
| Date
| Reply #3 on Thu 24 Jul 2008 08:13 PM (UTC) |
| Message
| | You would place it in exactly the same spot you put the previous expression. And yes, to turn on regular expression mode, it's just a checkbox in the window somewhere (I think the full text is something like "pattern is a regular expression"). |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | | Top |
|
| Posted by
| Smoothfonzo
(10 posts) Bio
|
| Date
| Reply #4 on Thu 24 Jul 2008 08:23 PM (UTC) |
| Message
| | Ok, maybe I'm missing something, but I did as suggested and it's still doing the same thing. I altered the trigger from (.*) to (\w+) | | Top |
|
| Posted by
| David Haley
USA (3,881 posts) Bio
|
| Date
| Reply #5 on Thu 24 Jul 2008 08:46 PM (UTC) |
| Message
| So it still matches:
You attack Mother's right hand, doing FATAL damage!
and the captured text is:
Mother's right hand, doing FATAL damage!
right? |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | | Top |
|
| Posted by
| Smoothfonzo
(10 posts) Bio
|
| Date
| Reply #6 on Thu 24 Jul 2008 08:59 PM (UTC) Amended on Thu 24 Jul 2008 09:04 PM (UTC) by Smoothfonzo
|
| Message
| Actually, it matches only:
You attack Mother's right hand, doing FATAL damage!
Not sure what I'm doing wrong.
Whatever I change in my trigger, it always tends to match that exact line from the output of the attack command.
So, currently I have the trigger set as:
You attack (\w+)
So whenever I use the attack Macro, it still fires up the trigger.
So, one shows up as:
You attack Mother
and then it sees this as I use the attack command
You attack Mother's right hand, doing FATAL damage! | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #7 on Thu 24 Jul 2008 11:40 PM (UTC) |
| Message
| Thanks for the compliments. :)
To debug your trigger we need to see it. Can you please copy and paste it here, see: http://mushclient.com/copying |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Smoothfonzo
(10 posts) Bio
|
| Date
| Reply #8 on Fri 25 Jul 2008 12:03 AM (UTC) |
| Message
| Ahh, yes, thanks. I was wondering how to do that :) Now I know what the copy button is for.
<triggers>
<trigger
custom_colour="11"
enabled="y"
match="You attack (\w+)"
regexp="y"
sequence="100"
>
<send>bset 10
bset reflect
fury
disrupt
pw
op
oath quietly</send>
</trigger>
</triggers>
| | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #9 on Fri 25 Jul 2008 09:24 AM (UTC) |
| Message
| You need a bit of anchoring here.
Your regexp:
You attack (\w+)
matches anything with "You attack (some word)" in it.
For example if someone said to you:
Nick says, I hear someone said 'You attack pigeon with a fork'
... then your trigger would fire.
In your case you need to anchor both ends, namely:
^You attack (\w+)$
Now the line must start with "You attack" which solves the problem of people gossiping to you about attacks, and the trailing $ means that the word must be the last thing on the line.
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| David Haley
USA (3,881 posts) Bio
|
| Date
| Reply #10 on Fri 25 Jul 2008 04:57 PM (UTC) |
| Message
| | You might have to add "\." to account for the period at the end of the sentence if you anchor it on the end. (You need the backslash because the period normally means "any character".) |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | | Top |
|
| Posted by
| Smoothfonzo
(10 posts) Bio
|
| Date
| Reply #11 on Sat 26 Jul 2008 02:05 AM (UTC) |
| Message
| | Thanks guys, this works beautifully :) Thanks for all the help! | | 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.
34,635 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top