Selective highlighting

by Razenth

Back to Mechanic's Corner.

Razenth2009-02-04 20:54:41
I'm working in Mush, and trying to grab a line, and then highlight a specific word in that line. It seems like an easy task, but for the love of God I can't seem to get it right. Help?
Unknown2009-02-04 20:57:19
You have two choices: gag the line and echo it with ColourNote in your own variety of colors, and the second involves regular expressions that might make your head explode. smile.gif
Razenth2009-02-04 20:59:39
Throw the reg expressions at me. I'm thinking of uses those funny parenthesis to set up a subpattern and highlight the subpattern. Will that work?
Isuka2009-02-04 20:59:50
do you know what that word is ahead of time, or is it unique every time?
Razenth2009-02-04 21:01:58
I know it ahead of time, thank goodness. BUT...

Essentially, I was thinking of creating a quest-look function, like the one someone once wrote, and then having the system create permanent triggers that highlight those words. But until then, I'm just inputting lines manually.
Isuka2009-02-04 21:07:11
QUOTE (Razenth @ Feb 4 2009, 01:01 PM) <{POST_SNAPBACK}>
I know it ahead of time, thank goodness. BUT...

Essentially, I was thinking of creating a quest-look function, like the one someone once wrote, and then having the system create permanent triggers that highlight those words. But until then, I'm just inputting lines manually.


I'm unfamiliar with the concept. What does a quest-look function look for? and how?

if you know ahead of time, you can always just do a word highlight.
Razenth2009-02-04 21:08:07
The q-look would "look" at every word in the room desc, omitting common ones like, the, a, is, etc.

But let's get back to word highlighting! How do I perform my original request?
Unknown2009-02-04 21:09:18
You'd use lookahead and lookbehind assertions, so it'd come out something like this for your pattern:
CODE
(?<=^First part of the pattern )(.+?)(?= and the end of the sentence\\.$)

Thus, if you came across the line "First part of the pattern sits here and the end of the sentence." (great grammar!), you'd only end up coloring "sits here" with your highlight. I've not actually tested this, mind you, but I think it should work.
Unknown2009-02-04 21:09:47
I think the best option is to just trigger the word to be colored. It might appear colored in random spots, but that doesn't seem like a big deal.
Razenth2009-02-04 21:16:37
I can't seem to find the meaning of the < in the documentation. Wasit do?

Man, Iunno what's wrong with the room descs, but for some reason, placing startline and endline tokens at the front and ends of the line prevents Mush from capturing that line. I can take 'em out and it works just fine.
Unknown2009-02-04 21:50:54
I warned you it was complicated. Here's a description of the general idea, but don't expect to understand much of it (I sure don't).

What wrapwidth are you using? If your client is doing all the wrapping, you can trigger on an entire room description in a single trigger. If you're still wrapping the text in the game, however, you're bound to have lots of issues triggering these types of things.
Unknown2009-02-04 22:02:00
I'm not sure 100% what you're trying to do, but if you want certain words in the room description to be highlighted and/or gagged, but only when using qlook, you could do something like this:

I'm not sure how to code this in MUSH, someone else could tell you, this is just the idea:

Have the alias 'qlook' enable a class called QuestColors. Within this class have every word you want colored triggered to be colored, and every word you want gagged triggered to be gagged.

Then, outside of this class, have the 'you see exits' line triggered to disable that class, so that they only fire in the period in which you are looking at the room.
Razenth2009-02-04 23:08:32
I used your code Zarquan, and it worked after removal of the ^ and $. Thanks for the info on the wrapping. I'll look into it.