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.
 Entire forum ➜ MUSHclient ➜ General ➜ Parsing based on color

Parsing based on color

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


Posted by Katie Love   (19 posts)  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! :-)
Top

Posted by Nick Gammon   Australia  (23,102 posts)  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
Top

Posted by Katie Love   (19 posts)  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
Top

Posted by WillFa   USA  (525 posts)  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.
Top

Posted by Nick Gammon   Australia  (23,102 posts)  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
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.


18,562 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.