Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ VBscript ➜ partial colour match

partial colour match

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by PJ   USA  (48 posts)  Bio
Date Fri 14 May 2004 03:09 PM (UTC)
Message
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
Top

Posted by Nick Gammon   Australia  (23,162 posts)  Bio   Forum Administrator
Date Reply #1 on Sat 15 May 2004 02:50 AM (UTC)

Amended on Sat 15 May 2004 02:51 AM (UTC) by Nick Gammon

Message
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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


10,749 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.