Coloring

by Sylphas

Back to Mechanic's Corner.

Sylphas2005-06-07 04:39:08
So I'm throwing together a system to color enemies, and people from each commune, so I can follow battles more easily. So, one or the other is quite easy. Together, it's not quite so easy.

Is there any way to catch the color of a line of a text that comes in, and then just output it underlined? I know you can trigger based on color, but is there anything that will either just underline it, or actually send the color to the trigger so you can output that color, underlined?
Dias2005-06-09 11:18:26
#tr {Text.} {#sub {~Text.~}}
Sylphas2005-06-09 17:17:23
Ooo, that works. Only problem is it strips the space/punctuation following the name, because the trigger only matches if those are there.
Sylphas2005-06-09 17:33:41
*frown* Nevermind, my trigger is just being a bitch anyway. How in the world do I get it to match ONLY when you have a name followed by whitespace or punctuation? Using %g or %s still seems to match it in the middle of a word, and using a list of punctuation and space to match by does the same thing, and won't kick out a space again to the substitution. *mutter*
Nayl2005-06-09 17:55:25
Check special characters help for whitespace.
Or troll Zmud forums for 30 seconds.
Sylphas2005-06-09 18:20:12
I've tried #TR {({@enemies_now})({ |,|.|!|?|'s}), and it still matches NaylBob. Then I switched to #TR {({@enemies_now})%g}, and it does the same thing. Same with %s. As far as I can tell, it should only match on "Nayl", "Nayl!", "Nayl.", "Nayl,", "Nayl?", "Nayl's", and "Nayl ". But it doesn't.
Terenas2005-06-09 18:45:29
I'm confused why you have to make it so complicated. When would you ever hear someone say something like, "NaylBob"?

Just make it as simple as you can and just match the word and color it. So what if it colors wrong once in a while, it's not some big deals.
Sylphas2005-06-09 18:57:52
Because I would be annoyed to the point of deleting the whole thing the first time it colored half of a word. Nayl isn't going to be a problem, but some names conceivably could be. I hate writing sloppy code like that.
Unknown2005-06-09 19:03:23
I use {@Names}%q to trigger name highlights, and set the trigger to case sensitive for good measure. The only times it gets confused is when someone's name appears in someone else's title (or worse, their name is so generic that you see sentences starting with it, like Rain or something.)
Sylphas2005-06-09 19:09:08
Hmm. I have no clue why %q isn't working then. I'll have to poke at it when I get home.
Unknown2005-06-10 08:35:18
I'm not ENTIRELY sure what you're asking, but this is what I have for triggering people's names on enemy lists for example.

Make the trigger case sensitive, natch. Then this trigger below will prevent say Val's name appearing triggered at the beginning of Valandriel's, or the word valiant.

Val({^%w})

Trigger on Val when the next character proceding the name is NOT a letter. This will allow for punctuation and spaces, but not continuation of words (like when a sentence starts Valiant.)

Hope that's the kind of thing you're after.
Daganev2005-06-10 11:41:54
Just use RegExp... or REgular expressions, its much easier and if you search the forums you can find a thread on the exact code to use.
Sylphas2005-06-10 16:36:04
Hmm. So just ({@enemies})%q is working for me, and I haven't a clue as to why it was broken before. Now I can nicely highlight citizenship, and underline enemies. smile.gif
Terenas2005-06-10 16:49:37
I just want them to allow us to configure colors for enemies and allies directly from Lusternia. sad.gif
Sylphas2005-06-10 17:23:51
That'd be nice.
Unknown2005-06-10 18:00:34
Considering how easy it would be for Lusternia itself to color the names, I can only guess that it's not done on intention to not make combat that much harder.

Here's a regex pattern that'll match exactly any name out of the variable @enemies...

(?
Make sure the trigger is set to perl syntax, case sensitivity and that the names in @enemies are with correct case.

That's the most precise I've come up with after a LOT of tweaking, but it's a tad complex and probably shouldn't be done more often than once or twice, unless the rest of your system is really fast anyway.

Oh and, you'll need to make a separate trigger for every organisation you want to color, obviously. Unless you color them all the same.
Sylphas2005-06-10 18:09:50
You know, it'd be neat if you could italicize text too. *chin*
Terenas2005-06-10 18:13:59
QUOTE(Sylphas @ Jun 10 2005, 06:09 PM)
You know, it'd be neat if you could italicize text too.  *chin*
135476


You can with html since Zmud supports that.
Unknown2005-06-10 18:29:47
I use MXP to make prettier colors and styles, and it can do more really cool things like pseudo links (e.g., probe something by clicking the ID) or pop-up menus (e.g., buy/probe/enemy/whatever something).
Sylphas2005-06-10 18:40:36
Ooo. I've been poking at MXP for coloring, since it allows a lot more than standard ansi, but haven't done much more than that. I'll have to check it out.