Exact trigger matching in Zmud

by Melanchthon

Back to Mechanic's Corner.

Melanchthon2004-11-27 08:44:30
Is there any way to have Zmud recognize only an exact match for a color trigger?

If I do

CODE
#co {in} bold,green


Then it also hightlights 'spindly hindlegs' for example.

Anyway to just have it recognize 'in' by itself?
Unknown2004-11-27 10:56:38
errrr... just trigger it with a space before and after in. Simple enough, so #co { in } bold,green
Unknown2004-11-27 15:05:35
A better way to do this is via perl lookahead and lookbehind regular expressions.

However, that only works if you have one of the recent zmud Versions, 7.01 onwards I think, that feature perl syntax triggers. 7.04 has them.

Say you want to color "in" but only if it's not inside a word like "inside", you'd do this:

CODE
#REGEX {(?


(note how it says #REGEX, rather than #CW or #TR, you need to use regex so zmud knows you want a perl trigger. Alternatively select "perl regular expression" in the trigger editor)

Basically what you do here is tell zMud that the trigger should match the word "in", but only if there's no letters directly before (?



If you can't use perl triggers for some reason, you'll have to supply a number of delimiters that might follow the word you want to trigger, because it'll not always look like " in " but could also be "in," or "in!", which won't all be matched with { in }.

A way to do this without having to create a whole bunch of reflexes each with a different delimiter is to supply a delimiter list, like this:

CODE
#CW { in{ |,|.|!|?}} bold, green


However, this method has some drawbacks, for one you'll get in trouble if the word you want to color can also come with a linebreak right before or after it.
Also if you use the code above you'll not only color "in" but something like "in," or "in?". Granted, if you have spaces as delimiters, that doesn't matter, unless you color the background aswell, which you want to do apparently. duh.

If you can, use the lookahead and lookbehind trigger, it works much better than the delimiter list thing. Plus it's so much more elegant wink.gif

-David
Melanchthon2004-11-27 20:31:13
Many thanks!
Neale2004-11-27 20:53:50
Mm, regular expressions, yummy.
Unknown2004-11-28 02:36:43
Don't make me hungry.
Silvanus2004-11-28 02:59:48
Zaltan, you're lame tongue.gif

(Yes, Zaltan, and maybe others, might know what I'm talking about it, but most of you won't...) harhar1.gif
Unknown2004-11-28 03:03:39
bruce_h4h.gif An imposter!
Too bad you don't have your automobile to drive away in now.

On another topic - what's up with all these new emoticons? They're too... animated. E.g.:

:cm: mf_swordfight.gif fishing1.gif roflmao.gif jawdrop.gif beak.gif Lighten.gif evil.gif
Daganev2004-11-28 03:08:51
Does that look behind look forward syntax also work for a trigger like {David|Sam|Jhon} or some similiar list with 1,202 names in it?
Unknown2004-11-28 03:11:47
I think in regex you'd go
CODE
(David|Sam|John)?
instead.
Unknown2004-11-28 05:01:34
Do you really need look-ahead/look-behind regular expressions just to match the word "in" in a pattern? Why not just match it with something like "%sin%s" and then add any other pattern stuff for matching punctuation? (Too tired right now to lookup the match for punctuation...)
Unknown2004-11-28 08:59:21
QUOTE (Zarquan @ Nov 28 2004, 06:01 PM)
Do you really need look-ahead/look-behind regular expressions just to match the word "in" in a pattern? Why not just match it with something like "%sin%s" and then add any other pattern stuff for matching punctuation? (Too tired right now to lookup the match for punctuation...)

%p for matching any punctuation, and %q does the same except it matches at the start and end of a line.
Unknown2004-11-29 07:56:49
@Zarquan: Sure, if it does what you need...
Me I dislike how adding delimiters to a trigger pattern that gets colored will color the delimiter along... that's a bit messy especially if you have a bracket as a delimiter. zMud has a few bugs with coloring things, sometimes it colors too much, or the same number of letters just one line below the line it actually triggered...

(On a sidenote, I -think- the perl regex pattern matches faster than using zMud's %s-like wildcards, which might be interesting on large systems, I haven't actually ran benchmarks though. Just my impression)

Basically, try go with the easiest solution that does what you need, the more complicated the more likely it'll screw up... (I personally do think having a lookahead/lookbehind is pretty simple but meh)


@Daganev: That's the kind of triggers that made me figure out the perl stuff in the first place wink.gif I've been trying to do neat name coloring for years and perl does it just perfectly biggrin.gif Same syntax as before, just replace "in" with (?:@listofnames)

-David

P.S. on a related topic, has anyone of you figured out a way to do something like this:

#TR {{@guildnames|@allies}}
{#cw %if(%ismember(%1,@guildnames),6,%if(%ismember(%1,@allies),10))}

(What I'm trying to do is having a single trigger that matches for all names of importance, guildmates allies citizens etcwhatnot, and then have the trigger decide which list that name comes from and how to color it)

Problem with that kind of trigger is, zMud only really gives the correct matched parameters the first time the trigger fires on a line, but if it fires again on the same line then it'll give the parameters as before, rather than the parameter it fired on now.
Like, if Nikua is my enemy and Visaeris is my ally, and I have a line like this:
Nikua viciously jabs a rapier into Visaeris!
I'd end up coloring both Nikua and Visaeris as enemies, because the trigger first matched Nikua and found him an enemy, then matched Visaeris and got the wrong parameter and found him an enemy again... doh.gif

Anyone know how to do this?
I'm currently using a separate trigger for every names list and put those into stacked classes to determine which coloring should show up dominantly (allies should be colored as allies even if they're citizens too, etc)
Daganev2004-11-29 08:02:40
hmm, I don't have that problem. Using that perl script I'm finding the coloring to be perfect, except when a person is both a enemy and a citizen. (oddly there is one such case)

I have trigger on trigger on, and Case sensitive on. There is also a difference betwen #cw and #color... but other than that, I'm not sure what the problem is.
Unknown2004-11-29 10:00:23
That's odd... I've always had that issue, with all versions of zMud I've used so far... I don't even think it's a zMud thing, other clients seem to do the same... If a trigger provides parameters, it'll only "feed" the parameters once and if the trigger fires again on the same line, the "old" parameters are still used... I just tested it again, same thing. *cringe* that sucks.

I couldn't even solve it by using temp triggers that run an alias that create a new temp trigger so it's actually a new trigger that gets executed every time... then I just run into trigger loops. And delays won't work here 'cause that'd mean zMud won't match it again on that line.

And reparse/within lines multistates don't work 'cause zMud ends up matching the first instance again and again. gah. ranting.gif ranting.gif
Daganev2004-11-29 11:13:19
what code are you using?
Niara2004-11-30 08:44:03
Uhm, maybe try it via the zmud database?
Unknown2004-12-02 10:55:55
actually, "it feeds the old data" doesn't quite match it, usually it just doesn't feed any data at all...
Try this:

#TR {({David|zMud})} {#echo %1; #cw 12} "" {notrig}
#echo David sometimes hates zMud!!

According what you told the trigger to do, it should echo the word it matched, and color it red.
Now, it does color both red, but it only echoes once. Bleh.

Edit: It's not a question of where I get my data from. It's a general issue of zMud's trigger parsing
Thorgal2004-12-19 18:30:09
If I want to trigger the word "north" in a sentence, but I don't want it to fire at "northeast" as well, how should I do it?
Silvanus2004-12-19 18:56:09
As this is a question about colors, I'll go onto this:

I have a trigger to make my target be the #cw 11 (its light blue), on Daevos, who is #cw 10 (green), if I target Daevos the blue overrides it, but, if I target Aris #cw 12 (red), Aris is still red.... but.. if I target Shiro #cw 12 (red) also, the blue overrides it. Any ideas?