[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Wildcard Colours

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Wildcard Colours

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page


Posted by Zalethon   USA  (13 posts)  [Biography] bio
Date Thu 26 Apr 2007 07:54 PM (UTC)  quote  ]
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.
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Thu 26 Apr 2007 08:22 PM (UTC)  quote  ]

Amended on Thu 26 Apr 2007 08:23 PM (UTC) by Nick Gammon

Message
See: http://mushclient.com/faq - items 23 and 33.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Zalethon   USA  (13 posts)  [Biography] bio
Date Reply #2 on Thu 26 Apr 2007 10:10 PM (UTC)  quote  ]
Message
Is there any way to do it without Lua?

Overkill is better than underkill.
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Fri 27 Apr 2007 12:10 AM (UTC)  quote  ]

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
[Go to top] 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.


1,438 views.

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]