View Single Post
  #12  
Old 09-26-2009, 03:37 AM
Rar Rar is offline
Novice
 
Join Date: Jun 2008
Posts: 14
Default

Quote:
Originally Posted by Bellum View Post
Thanks for the help Rar =)

I really don't get what you're saying. I think you're trying to make it capture the string before the colour code gets turned on. I could be WAY off tho. This is a little bit over my head tho. I will keep messing around with it to try and get it up and running. Thanks everyone for your help.
When you see a colorless (grey) string, such as:

Saving Rar.

...then the actual string being sent to your client looks just like that, no funky ANSI sequences. (Not necessarily true, but will suffice for understanding this discussion.) However, when you see a string with any color in it :

## Untamedfurby was just defeated in battle by Nymbus!

...then the string being sent to your client has extra stuff in it. Each time the color changes in the string, it's because there's an ANSI sequence in it. The actual string your client receives looks more like:

^[31m## ^[37mUntamedfurby was just defeated in battle by Nymbus!

...where I'm using ^ to represent the esc char (ASCII #27). You don't see any of that funky stuff because whenever your client sees an escape sequence, it automatically converts it into a color change (and hides all that funky stuff). The ^[31m means "change to bright red", and the ^[37m means "change to grey".

When you use stuff like #action, it works off of the cooked text (with the escape sequences removed), so it ignores color (otherwise #actions would be tough to write on the fly!) However, if you use the actual scripting capability of your client (e.g. JScript/Perlscript), the incoming strings have all the escape sequences still attached. (I think with JMC in JScript, you access the incoming string with "$jmc->Event", which should be done in a method which you hook onto the incoming text handler. For example, if you named your input handling method "OnIncomingText", you would hook it with "$jmc->RegisterHandler("Incoming","OnIncomingText()". ) Look at your client's documentation for specifics on how to do all this.

Because the escape sequences are still intact, you can do perfect matches based on not just the text, but the color of the text as well.

Above, Serenity asked how to view the actual, uncooked string in your client. The method I described does so by changing the ASCII #27 escape to something else and then displaying the string. (If you left the #27 as is, then your client would just translate it into colors and you wouldn't see any of the escape sequence text you're looking for.)
Reply With Quote