[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]  Coloring single words on a line.
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Coloring single words on a line.

It is now over 60 days since the last post. This thread is closed.   [New subject]  Start a new subject   [Refresh] Refresh page


Posted by MushclientNewbie   USA  (33 posts)  [Biography] bio
Date Tue 30 Mar 2004 05:45 AM (UTC)  quote  ]

Amended on Tue 30 Mar 2004 05:48 AM (UTC) by MushclientNewbie

Message
It's been asked before and I read all I could out of what I found with search. But I am still very confused. What I want to do is color a single word on a line. For instance - someone's name on the who, scan, and where lists. Or - a 'nothing.' slot on my equipment list. Here's a sample equipment list:

<used as light>      (Glowing) a tarnished lantern
<worn on finger>     the ring of life
<worn on finger>     nothing.
<worn around neck>   nothing.
<worn around neck>   nothing.

As you can see, I don't have anything worn on the 2nd ring or either of the neck slots. Matching 'nothing' and coloring it has worked for me with this list, but the who lists matching and whatnot is where the problems come in. Especially when I watch that person in battle and it colors his damage returns. But - that is a bit too hard to describe I think. If any of you could help me re-color just the 'nothing' variable on this eq list I think I could work out what I needed elsewhere.

Oh, all the rest of the equipment slots are the same. < and > around a 'worn on.' I tried matching just those with the period at the end of nothing - but it still colored the whole line :(.
[Go to top] top

Posted by MushclientNewbie   USA  (33 posts)  [Biography] bio
Date Reply #1 on Tue 30 Mar 2004 11:08 PM (UTC)  quote  ]
Message
Hah, I got it to work. All I did was set the trigger text to:

" * nothing."

Then, selected the 'Regular expression.' box. Now, can anyone explain why that worked?!
[Go to top] top

Posted by Shadowfyr   USA  (1,776 posts)  [Biography] bio
Date Reply #2 on Wed 31 Mar 2004 12:13 AM (UTC)  quote  ]

Amended on Wed 31 Mar 2004 12:25 AM (UTC) by Shadowfyr

Message
You got lucky... lol

Seriously, though I really do mean that. * and . have completely different meaning in regular expressions than in normal triggers. Basically by licking 'regular expression', you are now telling it to look for:

<space><one or more of> nothing<any character>

This means that it would not only match what you intended, but something like:

"                                     nothingy"

"  nothing "


It would still capture that single word, but if you had a line like:

"He said:  nothing but net!"

it would still color the word, since there is at least two spaces, matching the " * " part and 'nothing' is followed by more stuff. It would also match:

"  nothingness!"

for the same reason and would color " nothingn" in that line, though you wouldn't notice the spaces it captured in any of these cases, unless you had it color the background as well.

To make it work as intended, and not match a lot of stuff you don't want you need to tell it to look for a real "." and an end of line. Since "." has a special meaning <any character>, you need to tell Mushclient you really do want a period by adding a "\". To tell it to look for the end of a line you use "$", so your trigger, to work properly, should be:

"nothing\.$"

This isn't 100% perfect, since it will match on 'any' line that contains "nothing." at the end, but it is as close as you can hope to get, since anything more precise would color everything on a line, not just the word you wanted.

However.. One trick you can use to get around this is to use two triggers:

"^<\w+ \w+ \w+>\s+nothing\.$"
Color: --what you wanted for the 'nothing' word--
Sequence: 99

"^<\w+ \w+ \w+>\s+"
Color: --what you want it to be normally--
Sequence: 100

"^" means, the following *must* be at the start of a line. "\w+" means it will only look for letters that can appear in a word and it will look for more than one. "+" works the same as "*" in regular expressions and means <find more than one of these>. "\s+" looks for any number of spaces. By setting one triggers "sequence" lower than the second one, you can color the entire line, then the second trigger will match and only recolor the first part of the line, returning it to the color you would normally see. The only issue with this is it means you need to make sure to use 'Other...' when picking colors, since the custom colors need to stay the same as the normal ANSI colors. But the "Other..." option is a lot nicer to work with anyway imho. ;)

main {
__if (Schrodinger_Cat is Alive or version >= "XP"){
____if version = "Vista" then Performance /= Number_of_Cores;
____call Functional_Code();}
__else
____call Crash_Windows();}
[Go to top] top

Posted by Nick Gammon   Australia  (19,605 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Wed 31 Mar 2004 06:41 AM (UTC)  quote  ]
Message
The simple answer is, that if you want to colour a single word on a line, make a *regular expression* consisting of simply that word.

eg.
Match: nothing
Regular expression: checked
Colour: whatever

Also check "keep evaluating" if you want to colour multiple words. (eg. "worn on finger" as well).

- Nick Gammon

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

Posted by MushclientNewbie   USA  (33 posts)  [Biography] bio
Date Reply #4 on Wed 31 Mar 2004 07:16 AM (UTC)  quote  ]

Amended on Wed 31 Mar 2004 07:19 AM (UTC) by MushclientNewbie

Message
Yeah, I noticed that 'nothing' was getting highlighted in room descriptions and everything else. So, I changed the trigger to match on:

 *> * nothing
Thanks for the regular expression help, though. Works better than the hack-kneed stuff I was doing ^^. I think I'll be able to get the who/where/battle matches worked out with this. Now, if I could just pick a color that didn't give me a headache...
[Go to top] top

Posted by Dinkybarrel   (1 post)  [Biography] bio
Date Reply #5 on Sat 03 Apr 2004 06:20 PM (UTC)  quote  ]
Message
Now... for some strange reason, I can't get this to work at all...

I'm trying to colour bodypart words on triggers like this one:

You will now attempt to parry attacks to your head.

I just want to highlight 'your head'. But either I don't have anything highlighted, or the whole line gets highlighted.

I originally used a '*your head*' because the words could pop up pretty much anywhere in the sentence depending on the attack. It worked pretty good other than the excessive amount of yellow I saw on my screen thanks to full line highlights. >_> But I'd like to clean up my screen a bit.
[Go to top] top

Posted by Flannel   USA  (1,230 posts)  [Biography] bio
Date Reply #6 on Sat 03 Apr 2004 07:53 PM (UTC)  quote  ]
Message
In the other thread, which is talking about this same sort of thing...
http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=4013&page=999999

this is talked about.

What you do is make your trigger match on 'your head' and check regular expression (the RegExp bit is important, it changes the way triggers match drastically)

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
[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.


3,930 views.

It is now over 60 days since the last post. This thread is closed.   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

[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]    [Web site powered by FutureQuest.Net]