|
Moab Beginner
Joined: 02 Aug 2008 Posts: 25
|
Posted: Sun Apr 18, 2010 7:58 pm
triggers for color |
Alright - so I have a nifty trigger:
#trigger {~[} {#color yellow}
And it works - whenever it sees a bracket it colors the line yellow.
What I would like is to color just the bracketed part (ideally something like ~[%w~]) and return to the default color of the line after
the pattern match - can't seem to do this. How can I make this happen?
Same thing happens with my prompt:
#trigger {h%d m%d s%d} {#color orange}
But then my command text is orange also.
Thanks! |
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Sun Apr 18, 2010 8:53 pm |
#CW will color just the word you want it to color.
This trigger, for instance:
Code: |
<trigger name="Highlight-t" priority="3940" regex="true" enabled="false" id="905">
<pattern>^(?:The ghost of )?(@c_name)</pattern>
<value>$_mem_num = %ismember(%1, @c_name)
$_clan = %item(@c_clan, $_mem_num)
$_c_color = @clancolor($_clan)
#if (@_s_highlight)
{
#IF (%item(@c_clan, $_mem_num) = "Shadow")
{
#cw 8
}
{
#cw $_c_color
}
}
#if (@_s_flag)
{
$_clan_echo = @formatclan($_clan, 1)
#sayadd " "$_clan_echo
}
#if (@_s_lvl)
{
#sayadd "("%item(@c_lvl, $_mem_num)")"
}
#if (@_s_class)
{
#sayadd "("%item(@c_class, $_mem_num)")"
}
#if (@_s_rank)
{
#sayadd "("%item(@c_rank, $_mem_num)")"
}</value>
</trigger>
|
Will only color:
Arreana Room of Repose
The name Arreana, it also happens to add a few things as well. But that's irrelevant to this conversation. |
|
|
|
DraxDrax Apprentice
Joined: 22 Mar 2009 Posts: 149
|
Posted: Mon Apr 19, 2010 1:00 am |
Use #SUB instead of #COLOR. It will let you substitute whatever you'd like, in place of the pattern received from the mud.
#TRIGGER {~[(%w)~]} {#SUB %concat("[",%ansi(yellow),%1,%ansi(default),"]")}
This will take any single word that is enclosed in brackets and color it yellow. |
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Mon Apr 19, 2010 1:45 am |
Doesn't #SUB run the risk of being laggy? I mean, if you can isolate the pattern to just the word you want to color, is #CW any more efficient than #SUB?
|
|
|
|
DraxDrax Apprentice
Joined: 22 Mar 2009 Posts: 149
|
Posted: Mon Apr 19, 2010 3:20 am |
#CW will color the entire pattern, and can't be used to isolate just part of the pattern. So you can't use #CW to recognize a word inside of brackets and color just the word yellow while leaving the brackets alone.
If you can, it's a good idea to use #COLOR or #CW, but if they can't accomplish what you want, as is the case here, then use #SUB.
#SUB triggers shouldn't slow down the client noticeably, if at all, so I wouldn't worry about lag.
#COLOR <- Colors the entire line that the trigger pattern is found on.
#CW <- Colors just the pattern of the trigger, leaving the rest of the line intact.
#SUB <- substitute something else in place of the trigger pattern. |
|
|
|
Martaigne Wanderer
Joined: 05 Jan 2002 Posts: 88 Location: Atlanta, GA
|
Posted: Mon Apr 19, 2010 6:04 pm |
#TRIGGER {(~[%w~])} {#PCOL yellow %x1}
This will isolate the part in brackets and color only this without having to #SUB a line. |
|
_________________ Unwritten Legends
Last edited by Martaigne on Mon Apr 19, 2010 6:07 pm; edited 1 time in total |
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Mon Apr 19, 2010 6:07 pm |
A question, though. Does #PCOL use #SUB internally? In which case they would hold the same efficiency, though #PCOL would obviously be easier to use.
|
|
|
|
Martaigne Wanderer
Joined: 05 Jan 2002 Posts: 88 Location: Atlanta, GA
|
Posted: Mon Apr 19, 2010 6:10 pm |
Beats me, honestly. I use this with the following regex speech highlighting script, so it hits OFTEN and I don't see any noticeable lag.
#TRIGGER {^([^"]*,) ".*"$} {#PCOL limegreen %x1} |
|
|
|
DraxDrax Apprentice
Joined: 22 Mar 2009 Posts: 149
|
Posted: Tue Apr 20, 2010 6:10 am |
Hadn't thought of #PCOL That'll work, and is a much tidier solution. Though the pattern would need to be: {~[(%w)~]} to color the word within the brackets, while leaving the brackets alone.
|
|
|
|
charneus Wizard
Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Tue Apr 20, 2010 6:25 am |
Depending on the trigger pattern, #CW is what he'll want to use.
That is, if the pattern is just simply ~[%w~], then use #CW, as it'll only color that portion, no matter what line it is in.
However, if the pattern is more complex, then use the #PCOL as mentioned above.
That is, if the pattern is ~[%w~] Charneus stands here waiting.
#CW, as mentioned above, colors just the pattern itself (not the whole line, as #COLOR does).
Charneus |
|
|
|
|
|