Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Delphi03
Novice


Joined: 20 Aug 2004
Posts: 37
Location: Illinois

PostPosted: Fri Aug 20, 2004 10:16 pm   

Color Codes
 
Hello All. I'm currently playing a MUD that doesn't send standard ANSI Escape sequences to signify color. The MUD sends stuff like ^YYellow and ^yDarkYellow. How can I set up zMUD to automatically change the incoming texts (^Y ^R ^G etc etc) to color?

Also, I would need to have anything that I send with the ^Y not be changed, as the server wouldn't know what to do. (ie: don't convert outgoing streams to ANSI codes)

Thanks in advance,

Jamie R. McPeek
Reply with quote
hykou
Wanderer


Joined: 29 Apr 2004
Posts: 63
Location: USA

PostPosted: Fri Aug 20, 2004 10:19 pm   
 
gotta use the #SUBSTITUTE and %ansi commands :>
Reply with quote
Delphi03
Novice


Joined: 20 Aug 2004
Posts: 37
Location: Illinois

PostPosted: Fri Aug 20, 2004 10:58 pm   
 
Can you give me an example of how I would set it up to work from the moment I connect to the MUD? Like, where would I put it? and perhaps an example of a way to change

text: ^YThis should be yellow.^N and now white.

to This should be yellow. and now white.
Reply with quote
megamog75
Enchanter


Joined: 20 Nov 2002
Posts: 627
Location: USA

PostPosted: Fri Aug 20, 2004 11:14 pm   
 
he means, just make a trigger for it.

#sub {~^Y} {%ansi(High,Yellow)}
or you could use #co, but that might get confusing.

You could creat a class just for coloring.

Type right into the command line or use the editor. something like so...

#class Color
#sub {~^Y} {%ansi(high,Green)}
#sub {^N} {%ansi(High,white)}
#class 0

use this to start with then if you want to add a color

#sub {^G} {%ansi(high,green)} color

and this will set it up for you
_________________
megamog75 Smile
I will do this.Nothing in my life matters except this.No moment in my life exists except this moment.I am born in this moment, and if I fail, I will die in this moment. Raistlin Majere
Reply with quote
Delphi03
Novice


Joined: 20 Aug 2004
Posts: 37
Location: Illinois

PostPosted: Fri Aug 20, 2004 11:34 pm   
 
Okay, so the trigger I am using is:

Pattern: ~^Y(*)

Value: #sub %ansi(High, Yellow)(%1)


This turns the line yellow, but puts () around everything. If I remove the () from %1, the color does not change.

How can I resolve this?


RESOLVED: #sub {%ansi(High, Yellow)%1}


Last edited by Delphi03 on Fri Aug 20, 2004 11:46 pm; edited 1 time in total
Reply with quote
Delphi03
Novice


Joined: 20 Aug 2004
Posts: 37
Location: Illinois

PostPosted: Fri Aug 20, 2004 11:42 pm   
 
Also, now that I've added more colors, I've noticed another problem..

Text: ^YDelphi ^N ^YGabriel ^N ^YSatan

Result: (Delphi (^YGabriel ^N ^YSatan))

Is there a way to check for nested coloring codes?
Reply with quote
fred@kuzel.ca
Beginner


Joined: 25 Nov 2003
Posts: 15
Location: United Kingdom

PostPosted: Fri Aug 20, 2004 11:44 pm   
 
Pattern: ~^Y

Value: #sub %ansi(High, Yellow)
_________________
Reply with quote
Delphi03
Novice


Joined: 20 Aug 2004
Posts: 37
Location: Illinois

PostPosted: Fri Aug 20, 2004 11:49 pm   
 
Fred,

using that pattern and value results in..

Text: ^YAt Recall

Result: At Recall

Basically just strips the ^Y and replaces that spot with color? It doesn't color any text after it.
Reply with quote
megamog75
Enchanter


Joined: 20 Nov 2002
Posts: 627
Location: USA

PostPosted: Sat Aug 21, 2004 5:54 pm   
 
This is the correct


#trigger {^Y(*)} {#sub {%ansi(high,yellow)%1}}

Sorry for the confusion eairlier, I have tested this and it does work.
_________________
megamog75 Smile
I will do this.Nothing in my life matters except this.No moment in my life exists except this moment.I am born in this moment, and if I fail, I will die in this moment. Raistlin Majere
Reply with quote
Delphi03
Novice


Joined: 20 Aug 2004
Posts: 37
Location: Illinois

PostPosted: Sat Aug 21, 2004 7:35 pm   
 
magamog75:

You are correct, this trigger will work to some extent, though it comes by severe errors. Please look at my other thread, fulling explaining my new problem:

http://www.emobius.com/phpbb/viewtopic.php?t=17302&sid=73dc7a8fa555815dcf858f047a0287a5

Do you think (or anyone else) that it would be possible to create a solution using #PCOL or #PSUB that could be used to work with the nested color codes from the server, as long as there were less than 99? (I think that's how many PCOL/PSUB XStart XEnd that exist.)
Reply with quote
Falan
Wanderer


Joined: 17 Aug 2004
Posts: 98
Location: OK, USA

PostPosted: Sun Aug 22, 2004 11:07 am   
 
Not sure why the multiple threads. Question

Would a variation of Lightbulb's Standard Multiline Approach work?
_________________
zMUD 7.05a
Reply with quote
Falan
Wanderer


Joined: 17 Aug 2004
Posts: 98
Location: OK, USA

PostPosted: Sun Aug 22, 2004 2:47 pm   
 
http://www.emobius.com/phpbb/viewtopic.php?t=17300

This sounds similar to your issue. See Vijilante's entry at the bottom, specifically
Quote:

zMud triggers fire once per line and your example shows multiple 'command packets' per line. This will require that the data be parsed out.

I'm pretty sure this holds true for your multiple color tags per line as well.
_________________
zMUD 7.05a
Reply with quote
Falan
Wanderer


Joined: 17 Aug 2004
Posts: 98
Location: OK, USA

PostPosted: Mon Aug 23, 2004 3:40 pm   
 
Since Vijilante said a trigger will only fire once per line, I staggered multiple copies of the triggers like this:
Code:

#TR y1 {~^Y(*)} {#SUB {%ansi(high,yellow)%1}}
#TR n1 {~^N(*)} {#SUB {%ansi(white)%1}}
#TR y2 {~^Y(*)} {#SUB {%ansi(high,yellow)%1}}
#TR n2 {~^N(*)} {#SUB {%ansi(white)%1}}
#TR y3 {~^Y(*)} {#SUB {%ansi(high,yellow)%1}}
#TR n3 {~^N(*)} {#SUB {%ansi(white)%1}}


#SH ^YThis ^N is ^Ya ^N Test
This is a Test

#SH ^YThis should be yellow.^N and now white.
This should be yellow. and now white.

However, it failed when I switched the tags.

#SH ^NThis ^Y is ^Na ^Y Test
This is a Test

I tested other colors as well.

#TR {~^G(*)} {#SUB {%ansi(high,green)%1}}

For example,

#SH ^GThis ^N is ^Ga ^N test
This is a Test
#SH ^YThis ^G is ^Ya ^G test
This is a Test

works fine. But, switching tags around reveals a color priority:

#SH ^NThis ^G is a ^Y test
This is a test
#SH ^NThis ^Y is a ^G test
This is a test
#SH ^GThis ^Y is a ^N test
This is a test
#SH ^GThis ^N is a ^Y test
This is a test
#SH ^YThis ^G is a ^N test
This is a test
#SH ^YThis ^N is a ^G test
Thisis a test

Color priority appears to be white, green, yellow (meaning white will overwrite green and yellow, green will overwrite yellow) until I tried this:

#SH ^YThis ^G is ^Na ^Y test
This is a test

It remembered yellow and colored it. Swapping ^G and ^Y loses all yellow.

I tested 5 colors: blue, white, red, green, yellow. That's the apparent order of preference. This will work correctly:

#SH ^YThis ^G is ^Ra ^N test ^B trying ^Yto ^Gfind ^Rcolor ^Npriority
This is a test trying to find color priority

The only other pattern I found was that when you repeat a color it restarts the color priority.
So, a 2nd ^Red will have priority over a 2nd lesser color: ^Y ^G ^R ^Y ^R ^G
While a 3rd lesser color gets priority over a higher color only listed twice: ^Y ^G ^R ^Y ^Y ^R

Here's the trigger sequence I finished with:
Code:

#CLASS SubColors
#CLASS TempStuff
#TR y1 {~^Y(*)} {#SUB {%ansi( high, yellow)%1}}
#TR g1 {~^G(*)} {#SUB {%ansi( high, green)%1}}
#TR r1 {~^R(*)} {#SUB {%ansi( high, red)%1}}
#TR n1 {~^N(*)} {#SUB {%ansi( white)%1}}
#TR b1 {~^B(*)} {#SUB {%ansi( high, blue)%1}}
#CLASS 0



Again, any colors out of priority sequence will be overwritten by the higher value color or the more repeated color. Make sure to change the names if you create more copies.

Maybe a Guru has more info on this.


{edited to add trigger names}
_________________
zMUD 7.05a

Last edited by Falan on Tue Aug 24, 2004 1:16 am; edited 2 times in total
Reply with quote
Falan
Wanderer


Joined: 17 Aug 2004
Posts: 98
Location: OK, USA

PostPosted: Mon Aug 23, 2004 4:05 pm   
 
Oh, yeah. Make sure you set your Settings Editor to

View > Sort by... > None

to keep the shown order.
_________________
zMUD 7.05a
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Mon Aug 23, 2004 4:26 pm   
 
Or Just take each line and parse it yourself with replaces :P Only downfall is that this compares Everything but if everyline contains color codes this is your best bet. (I added a space at all the %ansi so the forum wraps properly just remove the spaces to get rid of the syntax error)

#TR {^(*)$} {#SUB %replace(%replace(%replace(%replace("%1",^B, %ansi(high,blue),^R, %ansi(high,red)),^G, %ansi(high,green)),^Y, %ansi(high,yellow))}
Reply with quote
megamog75
Enchanter


Joined: 20 Nov 2002
Posts: 627
Location: USA

PostPosted: Wed Aug 25, 2004 3:31 am   
 
ok What I came up with is more than a simple Sub, I used a script I wrote for creating code and just rewrote it for you problem.
I have tested it on every example you have givin, and it works without fail.

copy and past this to your command line
Code:
#CLASS {Colors}
#VAR colurs {}
#VAR colors {}
#TRIGGER {~^(*)} {colurs="";colors="";#var colurs %replace({%1},"^","|");#forall @colurs {#if %left(%i,1)=N {#var colors %additem(%ansi(high,white)%right(%i,1),@colors)};#if %left(%i,1)=R {#var colors %additem(%ansi(high,red)%right(%i,1),@colors)};#if %left(%i,1)=G {#var colors %additem(%ansi(high,green)%right(%i,1),@colors)};#if %left(%i,1)=B {#var colors %additem(%ansi(high,blue)%right(%i,1),@colors)};#if %left(%i,1)=Y {#var colors %additem(%ansi(high,yellow)%right(%i,1),@colors)}};#sub %replace(@colors,"|"," ")}
#CLASS 0


If you have anymore, Just ask hehehehehehehehehehe
_________________
megamog75 Smile
I will do this.Nothing in my life matters except this.No moment in my life exists except this moment.I am born in this moment, and if I fail, I will die in this moment. Raistlin Majere
Reply with quote
Falan
Wanderer


Joined: 17 Aug 2004
Posts: 98
Location: OK, USA

PostPosted: Wed Aug 25, 2004 10:19 am   
 
And that's why it says Magician under your name. Nice Wink
_________________
zMUD 7.05a
Reply with quote
Delphi03
Novice


Joined: 20 Aug 2004
Posts: 37
Location: Illinois

PostPosted: Wed Sep 01, 2004 9:19 pm   
 
Looks like it works. Thanks all!
Reply with quote
Delphi03
Novice


Joined: 20 Aug 2004
Posts: 37
Location: Illinois

PostPosted: Fri Sep 03, 2004 4:03 am   Not fixed!
 
It appears I was a bit hasty in the assumption that things were working correctly. However, when I started actually using the triggers...things got a little weird.

^YAt the centre of Dead Moorgate^N
You are standing in the middle of a large crater that dominates the
centre of the city. Slopes lead up out of the crater in all
directions. Sooty black scorch marks cover the floor here, though
what caused them you cannot tell.
ZONE*0
Obvious Exits: ^G North South East West NorthEast NorthWest SouthEast SouthWest^N
Items here: ^Gshort twig^N

produces->

short twig
You are standing in the middle of a large crater that dominates the
centre of the city. Slopes lead up out of the crater in all
directions. Sooty black scorch marks cover the floor here, though
what caused them you cannot tell.
ZONE*0
Obvious Exits: short twig
Items here: short twig


and things can get even worse...


^GDelphi^N is a level ^G22^N ^CDWARF MONK^N
^GYou are^N a ^C^CSentinel^N^N of clan ^CRoUgH RiDeRs^N
Your subscription will expire on the last day of 9 - 2004
Strength ^C 15^N Mysticism ^C 10^N
Accuracy ^C 12^N Speed ^C 12^N
Dexterity ^C 9^N Constitution ^C 13^N
Awarded Role Play Points ^C 5^N / Available RP Points ^C 98^N
BEGIN DESCRIPTION*
^GDelphi & Kerdyk Gryndelle^C. Both Souls Reside In This Singular Body. You See
^CA ^wflicker^C In Their Eyes. Who ^RAre^C You Talking To? You'll Never Know...
END DESCRIPTION*
PORTRAIT:0
Your voice is A loud booming

Your current weapon offense is ^YALMOST GOD LIKE^N
Your current defense is ^YEXTREMELY GOOD^N
Your current armor is ^YGOD LIKE^N
Your attack mode is: ^YNormal^N
You are a member of the ^CAdventurer's Guild^N
You are a member of the ^CMoorgate Fighter's Guild^N
You are a Noble of ^YMoorgate^N
You are a Worshipper of ^CAnyana^N
You were born on Day 21 of Weeping Skies of the year 157
Under the sign of Thanos, slayer of Imperitar
You are 69 years old. (age modifier: ^YAccomplished^N
You have done divine damage ^C1^N time in your life...
Use ^CGUILDSTATS (GS) ^N for guild status information
Use the ^CFLAGS^N command for game flag settings

produces ->

FLAGS command for game flag settings In Their Eyes. Who Are You Talking To? You'll Never Know... 98 13 12 10 Sentinel of clan RoUgH RiDeRs 22 DWARF MONK
FLAGS command for game flag settings In Their Eyes. Who Are You Talking To? You'll Never Know... 98 13 12 10 Sentinel of clan RoUgH RiDeRs 22 DWARF MONK
Your subscription will expire on the last day of 9 - 2004
Strength FLAGS command for game flag settings In Their Eyes. Who Are You Talking To? You'll Never Know... 98 13 12 10
Accuracy FLAGS command for game flag settings In Their Eyes. Who Are You Talking To? You'll Never Know... 98 13 12
Dexterity FLAGS command for game flag settings In Their Eyes. Who Are You Talking To? You'll Never Know... 98 13
Awarded Role Play Points FLAGS command for game flag settings In Their Eyes. Who Are You Talking To? You'll Never Know... 98
BEGIN DESCRIPTION*
FLAGS command for game flag settings In Their Eyes. Who Are You Talking To? You'll Never Know...
FLAGS command for game flag settings In Their Eyes. Who Are You Talking To? You'll Never Know...
END DESCRIPTION*
PORTRAIT:0
Your voice is A loud booming

Your current weapon offense is FLAGS command for game flag settings
Your current defense is FLAGS command for game flag settings
Your current armor is FLAGS command for game flag settings
Your attack mode is: FLAGS command for game flag settings
You are a member of the FLAGS command for game flag settings
You are a member of the FLAGS command for game flag settings
You are a Noble of FLAGS command for game flag settings
You are a Worshipper of FLAGS command for game flag settings
You were born on Day 21 of Weeping Skies of the year 157
Under the sign of Thanos, slayer of Imperitar
You are 69 years old. (age modifier: FLAGS command for game flag settings
You have done divine damage FLAGS command for game flag settings
Use FLAGS command for game flag settings
Use the FLAGS command for game flag settings



megamog or others, do you think it's possible to fix this somehow? Otherwise, I will result to creating a proxy-gateway to convert the ^y to ANSI Escape sequences so they're properly picked up by zMUD...but I would rather not do that just for a game. Also, it doesn't show up in here because HTML won't allow it, but every time it matches ^* it removes that string, and leaves an extra space...so ^GGreen^N House would be Green__House with _ = space.

Thanks in advance for all the help and effort from everyone!

[EDIT]
Okay, using nextela's embedded replace method, I was able to solve all the problems that came with megamog's (very much thanks anyway!!) method. I believe this thread to be solved as is and again thank everyone very much for their time and effort.
[/EDIT]
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Fri Sep 03, 2004 12:35 pm   
 
Of course it is Laughing
_________________
Zmud Support Library
Zmud Knowledge Base
Reply with quote
Falan
Wanderer


Joined: 17 Aug 2004
Posts: 98
Location: OK, USA

PostPosted: Fri Sep 03, 2004 2:16 pm   
 
And that's why is says Enchanter under your name. Nice Wink
_________________
zMUD 7.05a
Reply with quote
megamog75
Enchanter


Joined: 20 Nov 2002
Posts: 627
Location: USA

PostPosted: Mon Sep 06, 2004 2:10 am   
 
hey in all fareness, I did not incounter the problems you did.
I saw the double spacing in my testing, however the script I wrote was the cause of that it was not made to take into account for an actual space to follow the color code.

But i did not see this flag problem you had, I am glad you fixed it and evern glader I had a chance to see Nexla's script.

Whish I could have helped more.
_________________
megamog75 Smile
I will do this.Nothing in my life matters except this.No moment in my life exists except this moment.I am born in this moment, and if I fail, I will die in this moment. Raistlin Majere
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net