|
Nyojin Beginner
Joined: 05 Nov 2005 Posts: 18
|
Posted: Sat Dec 10, 2005 6:52 pm
Simple highlight script gone wrong |
Could anyone point out to me where the flaw(s) is in this?
Code: |
#CLASS {Highlights}
#ALIAS adb {#add %1 @buddies}
#VAR buddies {}
#TRIGGER {@buddies} {#cw pink}
#CLASS 0 |
Thanks! |
|
|
|
nexela Wizard
Joined: 15 Jan 2002 Posts: 1644 Location: USA
|
Posted: Sat Dec 10, 2005 8:58 pm |
#CLASS {Highlights}
#ALIAS adb {#ADDITEM buddies "%1"}
#VAR buddies {}
#TRIGGER {{@buddies}} {#cw pink}
#CLASS 0 |
|
|
|
Nyojin Beginner
Joined: 05 Nov 2005 Posts: 18
|
Posted: Sun Dec 11, 2005 11:26 am |
Thanks! I forgot it was additem and not add.
|
|
|
|
Theragil Apprentice
Joined: 13 Feb 2004 Posts: 157 Location: USA
|
Posted: Sun Dec 11, 2005 1:40 pm |
Might also want to make the trigger on {%q{@buddies}%q} to reduce false hits.
|
|
|
|
int21h Newbie
Joined: 12 Dec 2005 Posts: 2
|
Posted: Mon Dec 12, 2005 4:25 pm |
I have a quick question related to this... what if instead of changing the color of the pattern or highlighting it I wanted to append text to the line that the text had happened on.
For instance if the pattern was
John the Male Dwarf
and I wanted to make it so that I saw:
John the Male Dwarf [Friend]
Somehow I need to capture the entire line and append text to the end. I was trying to do something like:
#TRIGGER {%q{@friends}%q(%*)} {#sub {%1 %2 ~[Friend~]}}
but that doesn't really work. I've had other derivatives of the solution working but then weird things would happen, for instance if I had a name in the list called Tow, and I saw a tower in a room description, it would fire the trigger. Its my understanding that the %q might help? |
|
|
|
Theragil Apprentice
Joined: 13 Feb 2004 Posts: 157 Location: USA
|
Posted: Mon Dec 12, 2005 4:47 pm |
The %q will make it so it only matches that as a word; %q matches a space, punctuation, or beginning or end of line. Making it case-sensitive can also help.
|
|
|
|
int21h Newbie
Joined: 12 Dec 2005 Posts: 2
|
Posted: Mon Dec 12, 2005 6:43 pm |
Well I'm trying to match 4 main cases...
Lord George
Lord George, The King of All
George
George, Lord of All
and not match the cases of
George's
George.
I tried with something like this:
#trigger {(%*)({@buddies}){@specialChars}(%*)} {#sub {%1 %2 %3 ~[Friend~]}}
where buddies is {George|John} and specialChars is {,| } but this doesn't match all of the cases, most notably a case where you have just the buddy's name without anything trailing.
Any hints?
Eventually I'd like to do something similar with spell effects too, like:
George is blinded! [F2 to cure]
that case is a little easier to tackle than this highlighting case though. |
|
|
|
Slaem Apprentice
Joined: 20 Sep 2005 Posts: 135
|
Posted: Tue Dec 13, 2005 6:05 am |
untested - can't remember if the #SUB parameters need quotes, like "%1", etc.
#TR {(*)({@buddies}){| |,}(*)} {#SUB {%1 %2 %3 [Friend]}} |
|
|
|
|
|