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

Gammon Forum

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

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Parsing based on color
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Parsing based on color

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


Posted by Katie Love   (19 posts)  [Biography] bio
Date Tue 23 Dec 2008 10:06 PM (UTC)
Message
Yes, it's another question. Since I'm meeting a dead end on my other little project as well, I figured I'd throw out where I'm stuck there.

Triggers only fire on a new line, correct?

Room descriptions are being given to me in one line, but are multicolored -- the description is in one color, weather conditions and objects in another, and players present in another. The only way I could think to get the players in the room is to trigger on * and parse for color within the text. The problem is, the color is lost to the trigger once it fires. I also can't seem to do a trigger "within lines".

Any thoughts on this one? I'm probably going about it completely the wrong way.

Thanks! :-)
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Tue 23 Dec 2008 11:03 PM (UTC)
Message
Yes, triggers fire at the end of a line (ie. when the newline is received).

As for matching colours, see http://mushclient.com/faq point 33.

Quote:

I also can't seem to do a trigger "within lines".


Using regular expressions, you can match a word in the middle of the line. However triggers are tested for when the newline is received.

- Nick Gammon

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

Posted by Katie Love   (19 posts)  [Biography] bio
Date Reply #2 on Tue 23 Dec 2008 11:29 PM (UTC)
Message
Nick,

I want to first say I've been reading these forums for the past several days. I have been very impressed to see how active you are with the MUSHClient community. In case you don't hear it much, I wanted to say thank you. Especially since many of the insights you have posted have been extremely helpful to me.

The issue I've been having is parsing colors within lines, rather than text. Taking a line that has multiple colors, and parsing each color differently. For this, I can't see a RegEx working, unless ANSI/MXP data is usable in a trigger.

Upon following the link you suggested, I came across a section called "Style Runs". It looks like that may solve my problem. I'll play around with it a bit. If I continue to have issues, I'll just bump my post :-).

Thanks again,

-Katie
[Go to top] top

Posted by WillFa   USA  (525 posts)  [Biography] bio
Date Reply #3 on Wed 24 Dec 2008 02:02 AM (UTC)
Message
By the way, the color matching filter on triggers applies to the first character of the line.

Setting the match color to the description color should filter out a lot of the noise.
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #4 on Wed 24 Dec 2008 02:22 AM (UTC)
Message
The colour matching applies to the first character of the matched text (this isn't necessarily the first character of the line, if you are using a regular expression).

Katie, style runs are definitely what you want, each style run is a sequence of characters that shares the same style (eg. colour, boldness, italic, etc.).

Using Lua scripting, the style runs are made available to the trigger script, so you can readily find the colour of any part of the line.

If can also be done in other languages, but a bit more laboriously.

Check out http://mushclient.com/modules and look for getstyle.lua - that lets you find what colour any character in a style run is. (eg. if you want to know what colour the text at column 15 is).

Thanks for the compliments, by the way. :)

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


4,296 views.

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

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

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]