Parsing based on color

Posted by Katie Love on Tue 23 Dec 2008 10:06 PM — 5 posts, 25,256 views.

#0
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! :-)
Australia Forum Administrator #1
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.
#2
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
USA #3
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.
Australia Forum Administrator #4
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. :)