Official Nodeka Board  

Go Back   Official Nodeka Board > Nodeka > Scripting > UMC

Reply
 
Thread Tools Display Modes
  #11  
Old 09-25-2009, 10:52 PM
Bellum Bellum is offline
Novice
 
Join Date: Sep 2009
Posts: 25
Default

Quote:
Originally Posted by Rar View Post
Sure, just cook the output and spit it back out. For example, way back when I was building my list of full strings with escape sequences, I had an #alias that was something like:

#alias {capture}{#action {%0$$0%1}{#scr showString(%0$$0%1);#unaction {%0$$0%1}}

So if I were looking for the full ANSI string for say, Caller clan chat, I could type "capture Caller:". The next time a string with "Caller:" appeared, it would send that line to the showString function.

In the showString function, I would take the string passed to it, then do a simple search and replace of ASCII #27, which is the character used to initiate an escape sequence, to something readable (e.g. "<ESC>"). Then the function would spit that string back out for viewing. Since the escape char #27 was no longer present, the string would show with the code laid out - the color codes and such are treated as plain text since there's no esc char.

(There are other concerns that pop up in practical usage - for example, you'll need to do more replaces if semicolons are your client command delimiter, since many codes are of the form <ESC>#;##m. The above is the main gist of the solution, though.)
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.
Reply With Quote
  #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
  #13  
Old 09-29-2009, 09:57 PM
Ahriman Ahriman is offline
Wanderer
 
Join Date: Sep 2009
Location: Maine, USA
Posts: 3
Default

I understand the majority of what you're saying, Rar. I know there's just one key piece that I'm missing... and that is this: which character(s), exactly, represent ASCII #27? Would you type ESC? Or would you type its hex value, 1B? Is it universal? Thanks for taking the time to explain this stuff.
________
Web Shows

Last edited by Ahriman; 09-04-2011 at 08:11 AM.
Reply With Quote
  #14  
Old 10-02-2009, 02:24 PM
Rar Rar is offline
Novice
 
Join Date: Jun 2008
Posts: 14
Default

Quote:
Originally Posted by Ahriman View Post
I understand the majority of what you're saying, Rar. I know there's just one key piece that I'm missing... and that is this: which character(s), exactly, represent ASCII #27? Would you type ESC? Or would you type its hex value, 1B? Is it universal? Thanks for taking the time to explain this stuff.
Its printable ASCII representation is a little arrow pointing left. I don't think you can actually "type" it on your client, however. In Perl/etc., you would just assign a variable to chr(27) (or your language's equivalent).

$ESC = chr(27);
$text =~ s/$ESC/%%/g; // replaces #27 with %%
Reply With Quote
  #15  
Old 10-02-2009, 08:17 PM
Ahriman Ahriman is offline
Wanderer
 
Join Date: Sep 2009
Location: Maine, USA
Posts: 3
Default

Ahh, gotcha. It's like the Voldemort of ASCII characters: That Which Shall Not Be Typed.
________
LIVE SEX

Last edited by Ahriman; 09-04-2011 at 08:12 AM.
Reply With Quote
  #16  
Old 01-27-2010, 06:12 AM
Bellum Bellum is offline
Novice
 
Join Date: Sep 2009
Posts: 25
Default Bump

I know this thread has been dead for a while but I came back to try this again and I got it work.

Code:
#alias {grab} {#action {$$0} {#script umc.getEvent();#script umc.setVar("raw", umc.getEvent());#unaction {$$0}}
it will variable the string you need to the varaiable raw without the esc char, you will have to add the char in your self like Rar has mentioned.

Thanks for everyones help on this.

Last edited by Bellum; 01-28-2010 at 09:13 PM.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:06 PM.


Design By: Miner Skinz.com
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.