Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4690
Location: Pensacola, FL, USA

PostPosted: Sun Aug 13, 2006 4:53 am   

Why doesn't this work?
 
#TRIGGER {(%w)} {#IF (%colorname( %1)!=536870911) {#CW %1}}

Why doesn't this work? It seems to only test the first word of a line, though i see no reason why it wouldn't fire for every word.
_________________
Discord: Shalimarwildcat
Reply with quote
edb6377
Magician


Joined: 29 Nov 2005
Posts: 482

PostPosted: Sun Aug 13, 2006 5:06 am   
 
i thought %w was for word. so basically it triggers on any line that begins with a word?
i would think you would have to #TRIGGER {(*)} etc. then split the line from there?

Thats my inital reaction i will think on it more and see what i come up with. I have to run to work now so im sorry for the abbreviated response.

Edit: hmm ^(%w) would be a new line beginning with a word. So you got me. (%w) should check every word it recieves from the mud. Interesting.
_________________
Confucious say "Bugs in Programs need Hammer"
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4690
Location: Pensacola, FL, USA

PostPosted: Sun Aug 13, 2006 5:08 am   
 
yes, but i have no delimiters to make it only fire there... every word on the line SHOULD match the trigger and make it fire
_________________
Discord: Shalimarwildcat
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Sun Aug 13, 2006 8:49 am   
 
ZMud picks the largest pattern in a line, and also the first one it can find. Since one word is--as far as %w is concerned--no larger than any other word, ZMud picks the first one. You should notice that it won't fire on the first word when that first word consists of letters and symbols (ie, Claaw'vor, pea-brained, etc).

If you are after a word in a specific position, you will have to better define your pattern.
_________________
EDIT: I didn't like my old signature
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4690
Location: Pensacola, FL, USA

PostPosted: Sun Aug 13, 2006 9:28 am   
 
what that trigger is supposed to do, is on every word that is supported by %colorname, color it its appropriate color, i was just trying to to it without using a stringlist, but obviously i failed

why is it that '#CW red red' will fire multiple time on a line, but not this?

by the logic you present the first instance would satisfy the trigger and it wouldnt fire anymore, yet it does fire multiple times on a line
_________________
Discord: Shalimarwildcat
Reply with quote
saet
Apprentice


Joined: 12 Jun 2006
Posts: 106

PostPosted: Sun Aug 13, 2006 2:55 pm   
 
I really don't think such a trigger is worth the incredible amount of extra processing that zmud has to do.
Reply with quote
edb6377
Magician


Joined: 29 Nov 2005
Posts: 482

PostPosted: Sun Aug 13, 2006 4:46 pm   
 
may not be but its what he wants.

FIrst off
If the color does not exist, the clNone color is returned which has a value of 536870911.

As such %colorname() is used for returning the value of a color for the windows api interface i.e. %colorname(red). So thats not going to work for what you want i dont believe.

Now to answer your other question.

1. Both of these triggers turn EVERY word black.
#TRIGGER {(\a+)} {#CW %1} - Check mark Perl Expression
#TRIGGER {(%w)} {#CW %1}

However This trigger turns every word red
#TRIGGER {(%w)} {#CW red}

MOST IMPORTANTLY
#TRIGGER {(%w)} {#CW %1 red} Makes a trigger for every single word ONLY at the beginning of the line.

So this means #CW and the checking is done on every word.

Next segment

If i change the trigger to echo the %colorname it only checks the first word in each line. thusly showing the colorname in the first line
#TRIGGER {(%w)} {#ECHO %colorname(%1)}

So the reason its happening only on the first line is because of the type of command you are trying to use.

However substitute command replaces every word with its color name.
So here is my recommendation.

CHANGE TO AN ANSI TRIGGER AND FIGURE OUT WHICH COLORS YOU WANT TO TRIGGER.

i.e.

#TRIGGER {(%e[1;35m) triggers magenta and work from there. You can copy and paste the colored text into the trigger and it will make it.
_________________
Confucious say "Bugs in Programs need Hammer"
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Mon Aug 14, 2006 5:22 pm   
 
Keep in mind that the trigger only fires once per line. So (%w) is only going to capture the first word on the line. The code that loops through all matching words on the line is actually done in the #CW code, not in the original trigger, which makes #CW a bit of a kludge.

So, in your original trigger, the #IF statement is only executed once for the first word.

Also, I'm not sure if #CW recalculates the color for each match. It was never designed to do this. But just remember that it's #CW that is loop through all matching words, not the original trigger itself.
Reply with quote
edb6377
Magician


Joined: 29 Nov 2005
Posts: 482

PostPosted: Mon Aug 14, 2006 6:25 pm   
 
sounds like you are saying
Code:

 i would think you would have to #TRIGGER {whatever pattern for lines he wants to match} etc. then split the line from there?


Is the way to approach this then?

Then take the value from %trigger and split it and check each word that way?
_________________
Confucious say "Bugs in Programs need Hammer"
Reply with quote
Taz
GURU


Joined: 28 Sep 2000
Posts: 1395
Location: United Kingdom

PostPosted: Mon Aug 14, 2006 9:30 pm   
 
Zugg wrote:
The code that loops through all matching words on the line is actually done in the #CW code, not in the original trigger, which makes #CW a bit of a kludge.

Eewwwww Wink

Perhaps this is something to think about, possibly an extra trigger option in CMUD? I would imagine that people may want something similar to what can be done with #CW but instead of coloring words do something else with them say for instance count them.
_________________
Taz :)
Reply with quote
Qiz
Novice


Joined: 14 Aug 2006
Posts: 34
Location: Sweden

PostPosted: Mon Aug 14, 2006 9:33 pm   
 
I'd trigger on (*) to get everything from every line.
From there on:

loop and use:
%pos is used to check for the next whitespace
%left is used to get the leftmost word of the line
%delete is used to remove that word from the line

when %pos returns 0 there are no more whitespaces left, so break the loop and then get the last word of the line

example:
looping over: "towards end of line"
-> "end of line"
-> "of line"
-> "line"
when checking here, there are no more whitespaces left, but the last word remains.



Though, I agree it might not be worth it.
saet wrote:
I really don't think such a trigger is worth the incredible amount of extra processing that zmud has to do.

Unless you want to colour lots and lots of stuff, you might want to think about an alternative approach, such as creating a trigger for each word you want to colour.
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Sat Aug 19, 2006 6:29 am   
 
This may not be the most elegant solution to the problem, but it gets the job done. I borrowed heavily from a color wheel code I came across here on the forums.

The Colours variable has all possible zMud colors. The ColourTest alias displays them. The colorcreate alias creates a trigger that matches and colors each word. I included a bit so that words likes 'blues' and 'silvery' are completely colored but words like 'stand' don't have the middle colored tan.

I don't use alot of triggers but I did not notice much of a slow down.
Code:
#CLASS {ColourWheel}

#ALIAS ColourTest {#VARIABLE Colours {%replace( @Colours, " remove me |", "")};#FORALL @Colours {:1:#SAYPROMPT ~<color %i~>%i~</color~>%char( 32)};%cr}

#ALIAS colorcreate {#FORALL @Colours {#REGEX {(\b%i\a?\b)} {#SUBSTITUTE {~<color %exec(%replace( %i, " ", ""))~>%%1~</color~>}} {ColourWheel}}}

#VAR Colours {aliceblue|antiquewhite|aqua|aquamarine|azure|beige|bisque|black|blanchedalmond|blue|blueviolet|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|darkblue|darkcyan|darkgoldenrod|darkgray|darkgreen|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold|goldenrod|gray|green|greenyellow|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgreen|lightgrey|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslategray|lightsteelblue|lightyellow|lime|limegreen|linen|magenta|maroon|mediumaquamarine|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive|olivedrab|orange|orangered|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slategray|snow|springgreen|steelblue|tan|teal|thistle|tomato|turquoise|violet|wheat|white|whitesmoke|yellow|yellowgreen}
#CLASS 0


One this to thing to note is that some color can be remembers as the mud will not like have them, eg. cornflowerblue. The nature of that color brings me to the next point, it's fairly academic to put spaces in and have "dark gray" be matched and colored darkgray, but I leave this to the user to do. Finally I don't know if it occurs but i don't deal with color clashes but I few quick tests proved fruitful. Good luck and I hope it helps.
_________________
Asati di tempari!
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net