"\b" and Triggers

Posted by Serris on Sun 06 Dec 2009 03:59 AM — 8 posts, 35,452 views.

#0
I have a script that highlights a list of names using (@!enemies) and I also have a script that announces if one of them enters or leaves the area. The highlighter matches \b(@!enemies)\b. The problem I have is that the other script that announces when they enter/leave doesn't work while \b is used. Is there a way to make both work?

These are the exact matching lines.
Highlighter: \b(@!enemies)\b

Announcement: ^(\w+) has (entered|left) the area\.$
This one highlights all people entering/leaving the area so I added this in the script field

if "%1" == "(@!enemies)" then
Send("ct %1 in!")
end

I hope this is clear enough and thanks for any insight.
Australia Forum Administrator #1
This won't work:


if "%1" == "(@!enemies)" then


I presume in the enemies variable is a list of enemies, however the %1 == <something> matches an exact string, not some sort of list.

You would need to put the enemies in a table, and then do a table-lookup to see if it matches one of them.

Or, maybe:


Announcement: ^\b(@!enemies)\b has (entered|left) the area\.$

#2
^\b(@!enemies)\b has (entered|left) the area\.$

That doesn't seem to work while I have another trigger that highlights using \b(?:@!enemies)\b. When that's removed, the announcement trigger works perfectly.

Right now I have a list with a lot of names in the variable "enemies" and it look like this: Name1|Name2|Name3|Name4... I tried making a table before but failed miserably and crashed MUSH a few times. This was the easiest way to highlight names for me at least.

Would there be any other way to make these two compatible using just the match field?
Australia Forum Administrator #3
Well, it should work. We need more information.

Template:bug
Please help us by advising:
  • The version of MUSHclient you are using. Use the Help menu -> About MUSHclient.
  • A copy of the trigger, alias or timer you were using (see Copying XML)
  • The output from the MUD that caused the problem
  • The error message, if any, that you got (or other relevant output)
#4
Do your triggers have the 'keep evaluating' option set?
#5
Ah, sorry.
The version is 4.40

Here is the Highlight Trigger:

<triggers>
<trigger
custom_colour="7"
enabled="y"
expand_variables="y"
group="highlighter"
match="\b(?:@!enemies)\b"
regexp="y"
repeat="y"
sequence="100"
>
</trigger>
</triggers>

And here's the Announcement Trigger:

<triggers>
<trigger
enabled="y"
expand_variables="y"
match="^\b(@!enemies)\b has entered the area\.$"
regexp="y"
repeat="y"
sequence="100"
>
<send>
pt %1 has entered the area.</send>
</trigger>
</triggers>

Larkin: Yeah, both of them I tried "Repeat on Same Line" then one without and one with.
Australia Forum Administrator #6
No, you didn't have "keep evaluating" set. Without that set, only one will match if both are candidates. With it set (on both of them) it works:


<triggers>

  <trigger
   custom_colour="7"
   enabled="y"
   expand_variables="y"
   group="highlighter"
   keep_evaluating="y"
   match="\b(?:@!enemies)\b"
   regexp="y"
   repeat="y"
   sequence="100"
  >
  </trigger>

  <trigger
   enabled="y"
   expand_variables="y"
   keep_evaluating="y"
   match="^\b(@!enemies)\b has entered the area\.$"
   regexp="y"
   repeat="y"
   sequence="100"
  >
  <send>
pt %1 has entered the area.</send>
  </trigger>

</triggers>


Example:


You see Name1.
Name1 has entered the area.
pt Name1 has entered the area.

Amended on Tue 08 Dec 2009 04:05 AM by Nick Gammon
#7
I was confusing "Keep Evaluating" with another option. It works now as you said. Thanks for the help!