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
➜ General
➜ Wildcard Colours
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Zalethon
USA (13 posts) Bio
|
Date
| Thu 26 Apr 2007 07:54 PM (UTC) |
Message
| I know there's a way to match colours. Is there a way to detect the colour of a wildcard for use in a script? In this case I want to put a line of text from the MUD into the info bar, to alert me if I'm in another window, but I want it to keep its colours.. |
Overkill is better than underkill. | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #1 on Thu 26 Apr 2007 08:22 PM (UTC) Amended on Thu 26 Apr 2007 08:23 PM (UTC) by Nick Gammon
|
Message
| |
Posted by
| Zalethon
USA (13 posts) Bio
|
Date
| Reply #2 on Thu 26 Apr 2007 10:10 PM (UTC) |
Message
| Is there any way to do it without Lua? |
Overkill is better than underkill. | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #3 on Fri 27 Apr 2007 12:10 AM (UTC) Amended on Fri 27 Apr 2007 12:11 AM (UTC) by Nick Gammon
|
Message
| Yes you can, see below, however I should point out that you can make a plugin in Lua that does this particular function, even if the rest of your scripts are in some other language.
To get the colours in other languages, you need a couple of function calls:
Armed with all that you can redisplay it, send to another window, send to the Info bar, or whatever you want.
Bear in mind that triggers fire on a newline, however a large line might wrap, taking up one or more physical lines. GetLineInfo returns a physical line, not a logical line. You can tell from GetLineInfo (line_number, 3) if the line you are looking at has a newline at the end of it. If not, you can "walk backwards" (ie. subtracting 1 from the line number each time) until you find a line with a newline. The one after that is the start of the current logical line.
Example:
Line 101: The Cathedral Altar (newline)
Line 102: You are before the cathedral's altar. Those of ill luck or poor faith often
Line 103: come here to pray to their God for guidance, or chance. An aisle leads back
Line 104: south through the cathedral, while a large public board lies to the west. (newline)
Now in this example, if this was one big paragraph starting at "You are before the cathedral's altar ..." then the trigger will fire at line 104 (but not on receiving lines 102 or 103).
Thus, calling GetLinesInBufferCount will return 104. I would then "work backwards" (subtracting 1 each time), until I got a newline (by calling GetLineInfo). In this case, line 101.
I now know that lines 102 onwards (the one after the newline) comprise this paragraph.
For each of those lines you can pull out the colour information using GetStyleInfo. The call to GetLineInfo tells you how many styles there are in the line, so you know how many times to call GetStyleInfo.
|
- 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.
14,861 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top