A Macro and a Trigger: Both have similar patterns

Posted by Smoothfonzo on Thu 24 Jul 2008 06:53 PM — 12 posts, 36,800 views.

#0
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.
USA #1
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.)
#2
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+).
USA #3
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").
#4
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+)
USA #5
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?
#6
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!
Amended on Thu 24 Jul 2008 09:04 PM by Smoothfonzo
Australia Forum Administrator #7
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
#8
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>
Australia Forum Administrator #9
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.

USA #10
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".)
#11
Thanks guys, this works beautifully :) Thanks for all the help!