partial colour match

Posted by PJ on Fri 14 May 2004 03:09 PM — 2 posts, 12,561 views.

USA #0
In the game I play, people you can attack have a <PK> in front of their names on the 'who' list as well as the 'where' list.

If you can attack them because of your levels being close enough, it's displayed as a red 'PK' within brackets with the rest of the line being white or possibly other colours.

If you can attack them because they hold a certain item in the game, it's displayed as a yellow 'PK' with the same "maybe white maybe not" situation for the rest of the line.


Is there a way I can match only on the colour of the word PK in the line and change the entire line colour?
e.g. <PK> with red pk turns entire line to pink and <PK> with yellow turns entire line to a bright orange
Australia Forum Administrator #1
Yes you can do that. First I would make a trigger that matches on the "who" line regardless of colour.

Then look at one of the relevant (PK) lines by double-clicking a word in it, go to the menu Display -> Text Attributes -> Line Info. You should see something like this:


1: Offset = 0, Length = 12, Text = "Swordsman  <"
 No action.
 Flags = Hilite: no, Underline: no, Blink: no, Inverse: no, Changed: no
 Foreground colour ANSI  : 7 (White)
 Background colour ANSI  : 0 (Black)

2: Offset = 12, Length = 2, Text = "PK"
 No action.
 Flags = Hilite: no, Underline: no, Blink: no, Inverse: no, Changed: no
 Foreground colour ANSI  : 1 (Red)
 Background colour ANSI  : 0 (Black)

3: Offset = 14, Length = 5, Text = ">Nick"
 No action.
 Flags = Hilite: no, Underline: no, Blink: no, Inverse: no, Changed: no
 Foreground colour ANSI  : 7 (White)
 Background colour ANSI  : 0 (Black)

19 columns in 3 style runs

------ (end line information) ------


In this example you can see that the letters "PK" are in the second style run for the line (in your MUD's case it might be the third or fourth, which is why you do this).

Knowing this, you can then make a trigger script along these lines...


if getlineinfo (getlinesinbuffercount, 11) >= 3 then
  if getstyleinfo (getlinesinbuffercount, 2, 14) = 128 and _
     getstyleinfo (getlinesinbuffercount, 2, 15) = 0 and _
     getstyleinfo (getlinesinbuffercount, 2, 1) = "PK" then
    ColourNote "white", "red", wildcards (10)
  else
    ColourNote "white", "black", wildcards (10)
else
  ColourNote "white", "black", wildcards (10)
end if


What this is going to do is re-colour the line if it is red on black, has "PK" in it, for style number 2 on the line.

You would make the trigger omit the original line from output, and use the script to redraw it. You need to use a script file and not "send to script" or you won't see the new line.