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
➜ Coloring Phrases
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Krelm
(4 posts) Bio
|
| Date
| Sun 09 Oct 2011 06:41 PM (UTC) |
| Message
| Is it possible to color phrases in MUSHClient, without coloring the entire line of text? Like, say I walk into a room, and I see:
A tall man stands here, playing a fiddle.
Is there a way to just color "a tall man," without using the highlight function to individually highlight the words "a," "tall," and "man?"
Is there a way to possibly expand this? Another example, I walk into a room...
A tall man stands here, playing the fiddle.
A short man stands here, playing the harmonica.
A fat man stands here, being lazy.
Is there a way to get the client to recognize "a * man" and highlight it, while leaving the rest of the line blank? | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #1 on Sun 09 Oct 2011 09:51 PM (UTC) |
| Message
| Sure, something like this:
<triggers>
<trigger
custom_colour="2"
enabled="y"
keep_evaluating="y"
match="a .*? man"
regexp="y"
sequence="100"
>
</trigger>
</triggers>
 |
For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.
|
If you make a regular expression, it only colours the matching part. Make sure it isn't "anchored" to the start and end of the line (with ^ and $) or you will get the whole line.
Inside a regular expression the sequence .* is a wildcard, and .*? is a non-greedy wildcard.
The difference between greedy and non-greedy will become obvious if your test line was:
You see a tall man stands here, playing a fiddle with a short man.
With greedy it matches:
You see a tall man stands here, playing a fiddle with a short man.
(Because "man" appears twice).
With non-greedy it matches:
You see a tall man stands here, playing a fiddle with a short man.
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Krelm
(4 posts) Bio
|
| Date
| Reply #2 on Mon 10 Oct 2011 03:13 AM (UTC) |
| Message
| I was trying this out, and it -mostly- worked, but I ran into a few snags.
For instance, I have two triggers:
<trigger
custom_colour="17"
enabled="y"
keep_evaluating="y"
ignore_case="y"
match="A figure .*?cloak"
regexp="y"
sequence="100"
other_text_colour="purple"
>
</trigger>
For PC's wearing cloaks, which often show up as "a figure wearing a sandcloak" or somesuch.
And:
<trigger
custom_colour="17"
enabled="y"
keep_evaluating="y"
ignore_case="y"
match="a .*?cloak"
regexp="y"
sequence="100"
other_text_colour="green"
>
</trigger>
For cloak objects, which show up as "a blah blah sandcloak."
From what I can tell, the client sort of chooses randomly where to stick colors, and it often leads to a mess, and I'll see...
a short man says to a short figure in a drab sandcloak
A toned man looks down at a short figure in a drab sandcloak.
Where the underlined text is purple and the italicized text is green.
Is there any easy way to get around this, or if my list of stuff to highlight gets too long, will it always do this?
(As a side note, I realize that the reason this is happening is because the client is just looking for everything between and including "a" and "cloak" and sticking a color to it. A fix I can think of would be to not include "a" at all, but the MUD in question uses a metric ton of adjectives in the desc of the objects, so it would take pretty much forever.) | | Top |
|
| Posted by
| Krelm
(4 posts) Bio
|
| Date
| Reply #3 on Mon 10 Oct 2011 03:16 AM (UTC) |
| Message
| | Hmm, I just realized that my PC trigger didn't include anything about a build (EG, short), and that could have been part of the problem. That said, I noticed that a lot of color mashing happened in other places, so I suppose the question is still valid-- unless I made the same simple mistake in lots of places elsewhere. | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #4 on Mon 10 Oct 2011 06:20 AM (UTC) |
| Message
|
Krelm said:
From what I can tell, the client sort of chooses randomly where to stick colors, and it often leads to a mess, and I'll see...
There's nothing random about it. The triggers match in evaluation order (lower first), so if there are two matches and they overlap, you may get what appear to be strange results.
 |
Regular expressions
- Regular expressions (as used in triggers and aliases) are documented on the Regular expression tips forum page.
- Also see how Lua string matching patterns work, as documented on the Lua string.find page.
|
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | 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.
18,818 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top