|
Nattie Apprentice
Joined: 24 Jul 2008 Posts: 109
|
Posted: 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? |
|
|
|
oldguy2 Wizard
Joined: 17 Jun 2006 Posts: 1201
|
Posted: Sat Jul 26, 2008 7:22 pm |
Yes there is a much easier way.
Code: |
#REGEX {\b(?:@friends)\b} {#CW orange} |
|
|
|
|
Nattie Apprentice
Joined: 24 Jul 2008 Posts: 109
|
Posted: Sat Jul 26, 2008 7:47 pm |
That makes CMUD crash whenever I get a line with a friend's name in it. :-/
|
|
|
|
oldguy2 Wizard
Joined: 17 Jun 2006 Posts: 1201
|
Posted: 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.
|
|
|
|
Nattie Apprentice
Joined: 24 Jul 2008 Posts: 109
|
Posted: 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. :-/ |
|
|
|
oldguy2 Wizard
Joined: 17 Jun 2006 Posts: 1201
|
Posted: 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.
|
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4702 Location: Pensacola, FL, USA
|
Posted: Sat Jul 26, 2008 8:27 pm |
#TR {{@friends}} {#CW orange}
|
|
_________________ Discord: Shalimarwildcat |
|
|
|
Nattie Apprentice
Joined: 24 Jul 2008 Posts: 109
|
Posted: 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!
|
|
|
|
Zhiroc Adept
Joined: 04 Feb 2005 Posts: 246
|
Posted: 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. |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4702 Location: Pensacola, FL, USA
|
Posted: Sun Jul 27, 2008 3:31 pm |
#TR {%q{@friends}%q} {#CW orange}
There... word boundaries |
|
_________________ Discord: Shalimarwildcat |
|
|
|
|
|