[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  "\b" and Triggers

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

"\b" and Triggers

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page


Posted by Serris   (12 posts)  [Biography] bio
Date Sun 06 Dec 2009 03:59 AM (UTC)  quote  ]
Message
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.
[Go to top] top

Posted by Nick Gammon   Australia  (18,772 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Sun 06 Dec 2009 06:06 AM (UTC)  quote  ]
Message
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\.$


- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Serris   (12 posts)  [Biography] bio
Date Reply #2 on Mon 07 Dec 2009 01:27 AM (UTC)  quote  ]
Message
^\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?
[Go to top] top

Posted by Nick Gammon   Australia  (18,772 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Mon 07 Dec 2009 04:57 AM (UTC)  quote  ]
Message
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)

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Larkin   (278 posts)  [Biography] bio
Date Reply #4 on Mon 07 Dec 2009 02:44 PM (UTC)  quote  ]
Message
Do your triggers have the 'keep evaluating' option set?
[Go to top] top

Posted by Serris   (12 posts)  [Biography] bio
Date Reply #5 on Tue 08 Dec 2009 03:47 AM (UTC)  quote  ]
Message
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.
[Go to top] top

Posted by Nick Gammon   Australia  (18,772 posts)  [Biography] bio   Forum Administrator
Date Reply #6 on Tue 08 Dec 2009 04:04 AM (UTC)  quote  ]

Amended on Tue 08 Dec 2009 04:05 AM (UTC) by Nick Gammon

Message
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.


- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Serris   (12 posts)  [Biography] bio
Date Reply #7 on Tue 08 Dec 2009 04:58 AM (UTC)  quote  ]
Message
I was confusing "Keep Evaluating" with another option. It works now as you said. Thanks for the help!
[Go to top] 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.


2,296 views.

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]