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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Nattie
Apprentice


Joined: 24 Jul 2008
Posts: 109

PostPosted: Sat Jul 26, 2008 7:16 pm   

Why is this #CW trigger highlighting the whole line?
 
I have this trigger:

Code:
#TRIGGER {(%w)} {#IF (%ismember(%1,@friends)) {#CW orange}}


It is intended to highlight the name of anyone that is my friend, i.e. anyone I have saved to the @friends stringlist. The problem is, it doesn't just highlight their name, it highlights the whole line of text their name appears on, save for the last bit of punctuation at the end. So if the MUD gives me the line, "Friend walks in." it highlights everything but the last period.

To make things weirder, if I change the trigger to this, it highlights everything but the last word, plus the last bit of punctuation.

Code:
#TRIGGER {(%w) } {#IF (%ismember(%1,@friends)) {#CW orange}}


All I did was add a space after the (%w). So with the line, "Friend walks in." it highlights "Friend walks". If I get "Friend walks in, slaps you in the face, and leaves." it highlights "Friend walks in, slaps you in the face, and".

Is this a bug? Am I doing something wrong? Is there a better way to highlight members of a stringlist?
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Sat Jul 26, 2008 7:22 pm   
 
Yes there is a much easier way.

Code:
#REGEX {\b(?:@friends)\b} {#CW orange}
Reply with quote
Nattie
Apprentice


Joined: 24 Jul 2008
Posts: 109

PostPosted: Sat Jul 26, 2008 7:47 pm   
 
That makes CMUD crash whenever I get a line with a friend's name in it. :-/
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Sat Jul 26, 2008 8:06 pm   
 
Did you delete the other trigger? You should be able to just paste that in the command line. It will work just fine.
Reply with quote
Nattie
Apprentice


Joined: 24 Jul 2008
Posts: 109

PostPosted: Sat Jul 26, 2008 8:10 pm   
 
I did delete it. :( Pasting that into the command line crashes the program instantly, I tried a few times. So then I tried making it from the GUI instead and it doesn't crash immediately. But it crashes when I do a #SHOW Friendname just arrived. to test if it works. :-/

I haven't used any regular expression triggers before this, so I wonder if others would make CMUD crash too. Hmm... I hope not, now that I've looked at them they seem really useful, especially for stuff like this. :-/
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Sat Jul 26, 2008 8:14 pm   
 
No something is wrong. It shouldn't crash at all. Do have another variable with the same name or something? Do this...close CMUD then open an untitled session and enter that regex trigger on the command line. Then create a friends stringlist and enter a couple names. Then do a couple of #show lines with names from that list.
Reply with quote
shalimar
GURU


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

PostPosted: Sat Jul 26, 2008 8:27 pm   
 
#TR {{@friends}} {#CW orange}
_________________
Discord: Shalimarwildcat
Reply with quote
Nattie
Apprentice


Joined: 24 Jul 2008
Posts: 109

PostPosted: Sat Jul 26, 2008 8:31 pm   
 
Yes! You were right! I had a trigger called "friends" so I deleted it, and I changed the variable to friendlist just to be safe. It works great now. Thank you so much!
Reply with quote
Zhiroc
Adept


Joined: 04 Feb 2005
Posts: 246

PostPosted: Sun Jul 27, 2008 6:50 am   
 
shalimar wrote:
#TR {{@friends}} {#CW orange}

This isn't as good as the regex trigger, because it doesn't check for word boundaries. Thus, if one of the friends is "Tom", it will trigger and color this word in a phrase like "I'll see you tomorrow".

In fact, it is even better to make sure that the friends list has the appropriate capitalization, and to make the trigger be case-significant. So, names like "Sandy" are somewhat less likely to be matched when used as a normal noun.
Reply with quote
shalimar
GURU


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

PostPosted: Sun Jul 27, 2008 3:31 pm   
 
#TR {%q{@friends}%q} {#CW orange}

There... word boundaries
_________________
Discord: Shalimarwildcat
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD 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