|
Azah Newbie
Joined: 04 Aug 2015 Posts: 3
|
Posted: Tue Aug 04, 2015 11:52 am
#Read and ansi logging |
I'm trying to create a script that will copy in-game books.
So far I can copy the pages of the book into a log, but I can't figure out how to convert ansi color codes into my mud's local color codes. I went into Preferences, ANSI color, Color Syntax, and checked the Syntax Enabled box after setting up local color codes, and it beautifully converts any colored lines that I highlight with my cursor and paste in the command line. But for the life of me I can't figure out how to do that when saving to or #reading from a log.
Just to be clear, I want to:
1. Take colored text from the mud
2. Save it to a text file, either in ansi color or mud-appropriate color codes
3. Copy the text from the file back to the mud with mud-appropriate color codes. |
|
|
|
Daern Sorcerer
Joined: 15 Apr 2011 Posts: 809
|
Posted: Tue Aug 04, 2015 3:42 pm |
The %colorsyntax function does this.
|
|
|
|
Azah Newbie
Joined: 04 Aug 2015 Posts: 3
|
Posted: Wed Aug 05, 2015 12:51 am |
When I log in ansi, the format isn't %ansi(color) for the colored parts of the log, it looks (for example) like this:
[51 Human Inv] [1;36m([0;36mNew Thalos[1;36m)[0m Sultan Lunez Dra'lok, [35mthe [37mWhi[1;37mte Sha[0;37mdow [35mof [37mNe[1;37mw Tha[0;37mlos[0m
I'd like to be able to convert this string into my mud's color codes, so it looks like this:
[51 Human Inv] {C({cNew Thalos{C) {xSultan Lunez Dra'lok, {mthe {wWhi{Wte Sha{wdow {mof {wNe{Ww Tha{wlos{x
I have all those colors already set up in %colorsyntax.
So I may be misunderstanding ansi: is that HTML color coding instead of ANSI? I'm not a coder so I'm not even really sure what I should be looking for as far as conversions. |
|
|
|
Daern Sorcerer
Joined: 15 Apr 2011 Posts: 809
|
Posted: Wed Aug 05, 2015 2:56 am |
That is ANSI, and it should work fine with %colorsyntax. If you're trying to copy/paste snippets from a log file out of a text editor to test them, that likely wouldn't work because there are control characters included in the file that simple editors like windows notepad wouldn't be able to display, but if you're reading the file directly into CMUD with %read, then they will be there.
|
|
|
|
Azah Newbie
Joined: 04 Aug 2015 Posts: 3
|
Posted: Wed Aug 05, 2015 7:11 am |
Yeah, when I try to read that line, it inputs this into the mud:
[51 Human Inv] "[1;36m"("[0;36m"New Thalos"[1;36m")"[0m" Sultan Lunez Dra'lok, "[35m"the "[37m"Whi"[1;37m"te Sha"[0;37m"dow "[35m"of "[37m"Ne"[1;37m"w Tha"[0;37m"los"[0m"
So %colorsyntax isn't converting the HTML to my mud's color codes like I want it to, still. |
|
|
|
Anaristos Sorcerer
Joined: 17 Jul 2007 Posts: 821 Location: California
|
Posted: Thu Aug 06, 2015 8:06 am |
If you want to do your own color translation read this.
|
|
_________________ Sic itur ad astra. |
|
|
|
Daern Sorcerer
Joined: 15 Apr 2011 Posts: 809
|
Posted: Fri Aug 07, 2015 3:10 am |
I just tested this with the following steps:
1. In a clean session, Prefs => Session => Logging => Enable "Log ANSI color"
2. #log testlog.txt
3. #show %ansi(green)test%ansi(yellow)test%ansi(red)test
4. #log 0
5. Confirm by opening testlog.txt in notepad that the file contains the word "test" three times, along with ANSI color code sequences
6. Prefs => ANSI Color => Color Syntax => Check "Syntax Enabled", and type "{F" in the "Syntax for foreground color" box, "g" in the green box, "r" in the red box and "Y" in the bright yellow box
7. #file 1 testlog.txt
8. #show %colorsyntax(%read(1))
This correctly outputted "{gtest{Ytest{rtest", as the ANSI color codes within the log were transformed by %colorsyntax into the syntax expected by my settings. Does this look similar to your setup? |
|
|
|
|
|