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
YZilla
Beginner


Joined: 24 Jun 2002
Posts: 24
Location: Canada

PostPosted: Mon Jun 24, 2002 7:22 pm   

Colours and filtering
 
I've looked around in the forum archives for a while, but havn't found what I'm looking for specifically, so I'm going to start a new thread.

The MUD I play, Sharune, has two kinds of colouring option: ANSI, and a custom code specific for a custom Java client.

Out of sheer curiosity, I'm now attempting to understand that code, and program zMUD to display text correctly even when I'm recieving the custom client codes.

A typical coloured output that looks something like this:
<on neck> A Red necklace

With the CLIENT option toggled on, it looks like this:
&g<on neck> A &RRed &gnecklace

Getting the code converted to the ANSI format zMUD understand was no problem.

However, all hell breaks loose when I try to filter out the extra codes using #SUB.
Sometimes characters go missing(especially space), a new line is returned, and in extreme cases, a line which contains several colour tags will cause zMUD to echo the #SUB command instead of simply executing it.

Here's an example; this line should simply say: "A solid Human nods at a rugged Human." with the second "Human" coloured white.(The first "Human" is also coloured, but with a RGB system; I'm having the same problem with SUBing this as well)
A solid &x240220220Human nods at a rugged 15
    #SUB {}
&x240220220Human.

*The black text is actually displayed white. Just didn't think white was too easy to read on a forum.


The triggers I use (this one is for bright yellow) looks something like this:

Pattern: ~&Y(*)
#CW 14
#SUB {%1}

I've also tried using the value of:
#SUB {%ansi(14)%1}

but that didn't work too well either.

Please help.

Thanks in advance.



- This signature intentionally blank -
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Mon Jun 24, 2002 9:44 pm   
 
If you have version 6.16, you might want to try using MXP. Here is a sample trigger:
#TRIGGER {~&Y(*)} {#SUB {~<COLOR yellow~>%1~</COLOR~>}}

Doing it with MXP has the added benefit that you can also convert the ones in RGB notation. Here is the script that would do that:
#VAR convTable {0|1|2|3|4|5|6|7|8|9|A|B|C|D|E|F}
#ALIAS decColorToHex {#VAR firstCol %concat( %item( @convTable, (%1 / 16) + 1), %item( @convTable, (%1 16) + 1));#VAR secondCol %concat( %item( @convTable, (%2 / 16) + 1), %item( @convTable, (%2 16) + 1));#VAR thirdCol %concat( %item( @convTable, (%3 / 16) + 1), %item( @convTable, (%3 16) + 1));#VAR color %concat( "#", @firstCol, @secondCol, @thirdCol)}
#TRIGGER {~&x(%d)(*)} {decColorToHex %int( %copy( %1, 1, 3)) %int( %copy( %1, 4, 3)) %int( %copy( %1, 7, 3));#SUB {~<COLOR @color~>%2~</COLOR~>}}


Kjata
Reply with quote
YZilla
Beginner


Joined: 24 Jun 2002
Posts: 24
Location: Canada

PostPosted: Wed Jun 26, 2002 4:35 am   
 
Thanks Kjta.

Although the filtering codes are still not working the way I'd like them to be, your num-to-hex coverter is a lot more effecient than what I had before.

After doing some trial-and-error with various combinations, I've noticed that the colour codes in this MUD is a lot more complex than I thought, at least in implimentation.

The main problem I have is the way the custom client actually handles colours.

When a colour code is present, all text after that will be that certain colour, unless there is another colour tag that terminates the previous colour, or a &n tag will terminate all colouring and starts using the default green. However, if a line does not ternimate with &n, the used colour must carry on and be applied to the next line untill a &n or colour code is present. I've partially solved this by SUBing "~<color colourName~>%1", leaving the "~</color~>" out. Howver, this will totally mess up the text when a lot of colour switching goes on. (some words actually have different colours for each letter, looking something like "&C&x050215215M&x100235235u&x150255255j&x100235235u&x050215215o&x000195195n")

Another problem occurs where there are run-in prefixes, such as &W&x234234234Human.

What I really need, it turns out, is a method of SUBing where the tirgger will only read up to the next &, then colour the text between the two codes, while leaving the second colour tag intact for another trigger to activate on.

Would that be possible?

- This signature intentionally blank -
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Wed Jun 26, 2002 11:30 am   
 
How about we simplify...

#TR {~&(?)} {#SUB {%ansi(appropiatevalue)}
#TR {~&x(%d)} {#SUB {%ansi(appropiatevalue)}

Now we are not playing with the intervening text at all. We can examine what the color code is like this in the first trigger
#IF (%ismember("%1",@SimpleColors))

So that give us a start at determining what is the right thing to sub with. The second trigger provides number capturing and we will use Kjata's well written alias to handle that.

Altogether it goes something like this:
#VAR SimpleColors {g|R|Y|n}
#VAR OutputColors {green|red|yellow|default}
#TR {~&(?)} {#IF (%ismember("%1",@SimpleColors)) {#SUB {%ansi(%item(@OutputColors,%ismember("%1",@SimpleColors)))}}}
#TR {~&x(%d)} {decColorToHex %int( %copy( %1, 1, 3)) %int( %copy( %1, 4, 3)) %int( %copy( %1, 7, 3));#SUB {%ansi(@color)}}

This should leave any codes that it doesn't yet know intact so you can add them, and it should not have problems with running codes together and eating text blocks.
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Wed Jun 26, 2002 4:08 pm   
 
You know, I thought about just replacing the &Y and the others with the appropiate %ansi(), but it doesn't work. I know the susbtitution takes places because the color code doesn't appear, but the text doesn't get colored. You can test it with this simple one:
#TRIGGER {~&Y} {#SUB {%ansi(yellow)}}
#SH Testing ~&YTesting

The strange thing is that with Emulate Control Codes off, both lines (one with the subtitution from the trigger, and one with %ansi inserted by me) look the same.

Kjata
Reply with quote
YZilla
Beginner


Joined: 24 Jun 2002
Posts: 24
Location: Canada

PostPosted: Wed Jun 26, 2002 5:24 pm   
 
Thanks for the replies.

I've actually thought about using the method Vijilante proposed, but since this is my first "big" trigger project, I havn't tried coding a complex system like that yet. I think I will try it today.

The only problem with that method as I've noticed, is that some colour codes actually look something like &-y3. Instead of a single character following &, there is a short string of character noting a slight variatin of colour. Don't suppose it's too hard to fix. Just have a seocnd trigger that will check for that variation of code.

I've also talked about what I'm doing in the MUD forum, and I seem to have got the head Admin interested in this.
I think now I can even get a list of colour code and other special codes from the admins :)

- This signature intentionally blank -
Reply with quote
YZilla
Beginner


Joined: 24 Jun 2002
Posts: 24
Location: Canada

PostPosted: Wed Jun 26, 2002 6:37 pm   
 
Hm... SUB commands seems to have a lot of problem when they are executing codes instead of just replacing some text.

Using Vijilante's code, I've created a trigger which will SUB the colour code with the MXP
<color>
command.

Pattern:  ~&(?)(*)

#IF (%ismember( %1, @SimpleColors)) {
#SUB {~<color %item( @OutputColors, (%ismember( %1, @SimpleColors)))~>%2~</color~>}
}


testing with
#SH ~&RRed ~&rred~&yyellow~&RRed~&rred~&yyellow


I get the followin result:



Red (2) {
#SUB {red}
}yellow(3) {
#SUB {Red}
}red(4) {
#SUB {yellow}
}


The colouring is perfect. However... well, you can see what the problem is.
This was one of the problems I've had since day one. Even if individual triggers work, having two or three in the same line just makes everything go haywire.

- This signature intentionally blank -
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Wed Jun 26, 2002 10:53 pm   
 
This goes from simple to complex...oh well.

The first problem to overcome is the formatting. Where does the color code end and where does the text start.

Next problem is how to do the whole line all at once.
We will again use the SimpleColors and the OutputColors variables for the single character colors. For &x####### we can still use Kjata's code. The &-y3 you mention poses a problem since I have no clue what it should output to, but I can make some sort of region that will handle its processing. On with the show:

This is completely untested, but I did type it up in zMud and let the syntax checker find the )'s I forgot while typing it.

#TRIGGER {^&%*{CapturedLine}$} {CapturedLine=%quote( @CapturedLine);#WHILE (%pos( "&", @CapturedLine)) {CodeIndex=%pos( "&", @CapturedLine);CodeID=%copy( @CapturedLine, %eval( @CodeIndex+1), 1);#IF (%ismember( @CodeID, @SimpleColors)) {CapturedLine=%replace( @CapturedLine, %concat( "&", @CodeID), %concat( %if( @AwaitingClose, "</color>"), %ansi( %item( @OutputColors, %ismember( @CodeID, @SimpleColors)))));#IF (@AwaitingClose) {#ADD AwaitingClose -1}} { #IF (@CodeID="x") {CodeID=%eval( @CodeIndex+1);#WHILE (%isnumber( %copy( @CapturedLine, @CodeID, 1))) {#ADD CodeID 1};CodeID=%copy( @CaputredLine, %eval( @CodeIndex+2), %eval( @CodeId-@CodeIndex-3));decColorToHex %int( %copy( @CodeID, 1, 3)) %int( %copy( @CodeID, 4, 3)) %int( %copy( @CodeID, 7, 3));CapturedLine=%replace( @CapturedLine, %concat( "&x", @CodeID), %concat( %if( @AwaitingClose, "</color>"), "<color #", @color, ">"));#IF (@AwaitingClose) {#ADD AwaitingClose -1};#ADD AwaitingClose 1} { #IF (@CodeID="-") {#NOOP Unknown code function, replaced with `-;CapturedLine=%replace( @Captured, "&-", "`-")} {#NOOP All other unknowns.;CapturedLine=%replace( @CapturedLine, %concat( "&", @CodeIndex), %concat( "`", @CodeIndex))}}}};#SUB {@CapturedLine}}

The concept is to capture the line and then go through all of it and fix everything. Since a %* pattern is used I attempted the highest safety possible that of direct variable storage immediately followed by %quote on the variable. I have one such trigger in my own personal set that handles about 12 different types of lines for me. It has not failed once since using that setup.

Next item of concept is that it goes right into a while loop. Processing changed slightly in the beta's to speed things over all, I believe all issues with display order got corrected, but there may be some if you are using a beta.

I did not attempt to process any types of codes you have not provided a spec for instead they are simply ignored and the & is replaced with ` that is a reverse quote and zMud does not treat it as a special character so you should have no problems on that score.

I hope this works...
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Thu Jun 27, 2002 1:47 am   
 
There are a couple of problems with your script, Vijilante, but overall, it is great.

The biggest problem that you should know of first is that %quote won't work when a & is close to another letter. For that reason, you are going to need to replace all of the &'s with another character first. You can change:
CapturedLine=%quote(@CapturedLine)

to:
CapturedLine=%quote(%replace("%1", "&", "^"))

and then change all of the uses of & in that trigger to ^.

The converting of &x######### code sequences doesn't work too, but I'm not sure what exactly is the problem here. Also, you should not that decColorToHex already returns in @color the "#", so you do not need to add it in the trigger.

Anyway, great work on this!

Kjata
Reply with quote
YZilla
Beginner


Joined: 24 Jun 2002
Posts: 24
Location: Canada

PostPosted: Thu Jun 27, 2002 7:00 am   
 
Vijilante's code, after making the nessesary adjustments, is perfect at getting filtering out the codes. However, the colours are not showing.

I've attempted at varying Vijilante's code slightly to see if it would fix the problem, but no luck yet.

I've posted parts of the MUD's output below for the purpose of clarifying (or confuse people further) of the code.



&yListing of Gods and Immortals&n
&r-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-&n
&n[ Ancient God &n]&n &WHephos&K, King of &bGods&n

&cThere is &C1 &cvisible immortal online.&n

&yListing of Mortals of Good Racewar Side&n
&r-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-&n
&n[&n14&n &W&x240220220Human&n &n] Jaila
&n[ &KAnonymous&n ] Creishie
&n[&n13&n &y&x150100100Raukburhrum&n&n] Ruken
&n[&n12&n &cRiver&b-&gFaun&n &n] Tloiaeruo
&n[&n5 &n &W&x240220220Human&n &n] Kedales (&WRP&n)
&n[ &KAnonymous&n ] Draligan Er'Mithras
&n[&n11&n &Y&x230230150Elf&n &n] Seledrion

&cThere are &C12 &cvisible mortals online.&n

&cThere are currently 16 players online.&n
&cRecord number of players this boot - [19]&n
&r-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-&n

&p1h165/165e161/161m72/72pStanding


&p1h165/165e161/161m72/72pStanding
You are using:
<on head> &ga &Ggreen &ggoblin-skin &Gcap&n
<in ear> &ca &wfish&c-&wbone &cearring&n
<around wrist> &ga bracelet of &x230232250s&x240242255i&x250252255lv&x240242255e&x230232250ry&n &+g2leaves&n
<on finger> &-y3a ring of &yoak &-y3wood&n
<on finger> a ring of intertwined roots
<2-hand wield> &Ka gnarled black&gwood &Kstaff&n


&p61/It's partly cloudy, mild, and calm.
&p63/It's cloudy, cold, and calm.


-----------------------------------------------------

And the mess of codes below is what the in-game ASCII map looks like...


&zstrt13x9
&zdrk0
&z&g.&n&y^^&n&v&b&q&+b4&v^^&n&y^^&n&g...&n&y^^&n&yM&n
&z&g..&n&y^&n&v&b&q&+b4&v^^&n&y^&n&g......&n&g^&n
&z&K+&n&g..&n&v&b&q&+b4&v^^&n&g........&n
&z&K++&n&g.&n&v&b&q&+b4&v^^&n&g...&n&K+++++&n
&z&g&v*&n&K++&n&w&v^&n&v&b&q&+b4&v^&n&w&v^&n&W@&n&K++&n&g....&n
&z&g&v***&n&y&q&-y9+&n&v&b&q&+b4&v^^&n&g.&n&v&b&q&+b4&v^^^&n&g...&n
&z&g&v***&n&y&q&-y9+&n&g&v*&n&v&b&q&+b4&v^^^&n&g.&n&v&b&q&+b4&v^^^^&n
&z&g&v***&n&y&q&-y9+&n&g&v*********&n
&z&g&v***&n&y&q&-y9+&n&g&v*********&n
&zstop
&zcmap
&zdraw
&cThe Eastern Road&n&n
&gObvious exits:&c -North -East -South -West &n


The custom client actually cuts this part of the output, colour it, and display it in a section of the window separate from the main out-put.

----------------------------------
So far, I've identified the followying colour codes

&g (green)
&r (dark red)
&R (red)
&K (gray)
&c (dark cyan)
&C (cyan)
&y (yellowish brown)
&Y (yellow)
&W (white)
&w (slightly dark white)
&v (black text on green background)
&-y1, &-y2... (various shades of yellowish brown)
&-g1, &-g2... (various shades of green)

- This signature intentionally blank -
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Thu Jun 27, 2002 11:48 am   
 
I did some testing with it and found a few typos. I have also made the changes Kjata suggested. It still is not perfect. The only way to ever get it perfect would be for Zugg to add a complete data translation into the code. Anyhow it is doing some of the colors and only got confused on a few special chars. I would suggest turning off [] and <> in the preference to help with that. Here is is all in one class so you can readily integrate it.

#CLASS {TestColors}
#ALIAS decColorToHex {#VAR firstCol %concat( %item( @convTable, (%1 / 16) + 1), %item( @convTable, (%1 16) + 1));#VAR secondCol %concat( %item( @convTable, (%2 / 16) + 1), %item( @convTable, (%2 16) + 1));#VAR thirdCol %concat( %item( @convTable, (%3 / 16) + 1), %item( @convTable, (%3 16) + 1));#VAR color %concat( "#", @firstCol, @secondCol, @thirdCol)}
#VAR CAPTUREDLINE {}
#VAR CodeIndex {26}
#VAR CodeID {240220220}
#VAR SimpleColors {"Y"|"n"|"g"|"r"|"R"|"K"|"c"|"C"|"y"|"W"|"w"|"v"}
#VAR OutputColors {"yellow"|"default"|"green"|"bold,red"|"red"|"high,black"|"bold,cyan"|"cyan"|"brown"|"white"|"gray"|"black,green"}
#VAR convTable {0|1|2|3|4|5|6|7|8|9|A|B|C|D|E|F}
#VAR firstCol {F0}
#VAR secondCol {DC}
#VAR thirdCol {DC}
#VAR color {}
#VAR AwaitingClose {0}
#TRIGGER {^&%*{CapturedLine}$} {CapturedLine=%quote(%replace("%1","&","^"));#WHILE (%pos( "^", @CapturedLine)) {CodeIndex=%pos( "^", @CapturedLine);CodeID=%copy( @CapturedLine, %eval( @CodeIndex+1), 1);#IF (%ismember( @CodeID, @SimpleColors)) {CapturedLine=%replace( @CapturedLine, %concat( "^", @CodeID), %concat( %if( @AwaitingClose, "</color>"), %ansi( %item( @OutputColors, %ismember( @CodeID, @SimpleColors)))));#IF (@AwaitingClose) {#ADD AwaitingClose -1}} { #IF (@CodeID="x") {CodeID=%eval( @CodeIndex+2);#WHILE (%isnumber( %copy( @CapturedLine, @CodeID, 1))) {#ADD CodeID 1};CodeID=%copy( @CapturedLine, %eval( @CodeIndex+2), %eval( @CodeID-@CodeIndex-2));decColorToHex %int( %copy( @CodeID, 1, 3)) %int( %copy( @CodeID, 4, 3)) %int( %copy( @CodeID, 7, 3));CapturedLine=%replace( @CapturedLine, %concat( "^x", @CodeID), %concat( %if( @AwaitingClose, "</color>"), "<color ", @color, ">"));#IF (@AwaitingClose) {#ADD AwaitingClose -1};#ADD AwaitingClose 1} { #IF (@CodeID="-") {#NOOP Unknown code function, replaced with `-;CapturedLine=%replace( @CapturedLine, "^-", "`-")} {#NOOP All other unknowns.;CapturedLine=%replace( @CapturedLine, %concat( "^", @CodeIndex), %concat( "`", @CodeIndex))}}}};#WHILE (@AwaitingClose) {CapturedLine=%concat(@CapturedLine,"</color>")};AwaitingClose=0;#SUB {@CapturedLine}}
#CLASS 0

You will notice the addition of "AwaitingCloe=0" at the end, this is to cover any "</color>" that did not get added where they belong due to the color code already being replaced there. In order to fix that problem the whole thing would have to be reworked without using %replace, and would end up slower then a snail.
Reply with quote
YZilla
Beginner


Joined: 24 Jun 2002
Posts: 24
Location: Canada

PostPosted: Thu Jun 27, 2002 10:19 pm   
 
Thanks for all the help.
I still have problem using Vijilante's code - which seems to go into infinit loops a lot, - but based on his code, I managed to whip up something that finally works.



processedLine=%quote( %replace( @capturedLine, "&", "`"))
closeCTag = 0
#WHILE (%pos( "`", @processedLine)) {
codePlace = %pos( "`", @processedLine)
#IF (%pos( "`x", @processedLine)) {
curRGBNum = %copy( @processedLine, @codePlace + 2, 9)
numColToHex %copy( @curRGBNum, 1, 3) %copy( @curRGBNum, 4, 3) %copy( @curRGBNum, 7, 3)
@processedLine = %replace( @processedLine, "`x"@curRGBNum, %concat( %if( @closeCTag = 1, "</C>"), "<C ", @color, ">"))
closeCTag = 1
}
codeSingleValue = %copy( @processedLine, @codePlace + 1, 1)
#IF (%ismember( @codeSingleValue, @inputColours)) {
@processedLine = %replace( @processedLine, "`"@codeSingleValue, %concat( %if( @closeCTag = 1, "</C>"), "<C ",
%item( @outNameColours, %ismember( @codeSingleValue, @inputColours)), ">"))
closeCTag = 1
}
#IF (%ismember( @codeSingleValue, @ignoredCode)) {
@processedLine = %replace( @processedLine, "`"@codeSingleValue, "-")
}
codeDoubleValue = %copy( @processedLine, @codePlace + 1 , 2)
#IF (%ismember( @codeDoubleValue, @inputDoubleColours)) {
@processedLine = %replace( @processedLine, "`"@codeDoubleValue, %concat( %if( @closeCTag = 1, "</C>"), "<C ",
%item( @outDoubleNameColours, %ismember( @codeDoubleValue, @inputDoubleColours)), ">"))
closeCTag = 1
}
}
#IF (@closeCTag = 1) {processedLine = %concat( @processedLine, "</C>")}
#SUB @processedLine


You'll first notice that instead of directly modifying CapturedLine, it instead makes a second variable processedLine; I did this only to make debugging slightly easier.
Also, instead of replacing & with ^, I've used `. I did this becase the in game ASCII makes use of ^ to show quite a few variations of terrain/object, so it isn't a very practical choice to mark codes.

Testing with the special character "&" turned off, it's performed very well at filtering out the code and colouring the text.
The only problems now are its speed, which I never expected much of since it's quite complex, and the fact that it will occasionally go into an infinite loop because I did not put a protection code in to prevent it from happening. The looping won't be much of a problem, I believe, since I expect to have a list of all codes eventually, and it won't be too hard to whip one up if I really need it.

As far as this being my first zMUD script that's more than 3 lines, I'd say it's so far a success. :)

- This signature intentionally blank -
Reply with quote
YZilla
Beginner


Joined: 24 Jun 2002
Posts: 24
Location: Canada

PostPosted: Fri Jun 28, 2002 12:22 am   
 
Well, just did some in-game testing, and it's painfully slow.

I'll need to do some code-optimizaiton on this.


- This signature intentionally blank -
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Fri Jun 28, 2002 2:31 am   
 
Sweet! I am glad you got it working. From the code I am seeing you have no function to handle unknown codes, and that would cause your infinite loop. The only code optimization I can find is to else chain your if's the way I did. That was also why I started with what appeared to be the most often used codes on the if/else chain.
Reply with quote
YZilla
Beginner


Joined: 24 Jun 2002
Posts: 24
Location: Canada

PostPosted: Fri Jun 28, 2002 5:35 am   
 
I've done some optimization on the code a while ago, and they seemed to have, although very slightly, helped.

I mainly replaced the %repalace() expressions with a set of %delete() and %insert().
It's a slightly longer line, but I figured there is actually less processing because %replace() actually searches for the matching pattern inside the string. Since the position at which I want the string to change is already detected and stored in codePlace, I saw no harm in doing it the more basic way.

As for ELSE chaning, I've forgotten about it. It should speed it up slightly more.

With the basic colour trigger almost out of the way, I've been looking into some of the special colour codes, and boy, oh boy, they just get more and more complex.

&v, as it turned out, is not actually "make text black with green back ground", but rather, "make the prefixed colour the background colour."
So, to make a text have a red background, the code would be &R&v.
The good thing is that only the ACSII map makes use of back ground colours, and my plan is to have it completely extracted from the main out-put window. I might as well make a separate trigger to specifically handle the map, it doens't use RGB colours, and I'm only working with single char suffixed code and its +n#, -n# variations.

I think I'm going to give this colour trigger a bit of a rest after a bit more optimization, and work on the few other triggers which extracts combat, hp/stam, and day/weather information.

Below is a screenshot I took to post in the MUD forum. At this stage, the trigger was still slightly bugged and unoptimized. Some of the colours are wrong since I wansn't using #SHOW, but it still displays how well the code actually worked.

This has certainly been a huge learning experience for me. I plan to explore zMUD scripts even further as time goes by.



- This signature intentionally blank -
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Fri Jun 28, 2002 10:52 am   
 
I must say nice. Please post it to te completed scipts forum when you finish your optimizations.
Reply with quote
YZilla
Beginner


Joined: 24 Jun 2002
Posts: 24
Location: Canada

PostPosted: Sun Jun 30, 2002 2:34 am   
 
Well, there goes my plan to stop a while after more optimization.
I've done some more optimization on the code, mainly changing around the order of decection, letting the code that should trigger the most frequently in the begenning of the IF/ELSE chain and such.

Before I go on, a bit of picture teasing.



After some research on that the actual raw colour values of the basic ANSI colours are in RGB, and a few minutes of digging through log files and comparing it with the output from the custom client, I've decoded the &+n# / &-n# variation of the colour codes.

Simply put, it takes the RGB of the base colour n, then add/subtract to to it by the specified amount of intensities of #. In the 9 digit number format used by the MUD, each &+r2 would be two increments of 14 above the base number of &r. (&r = 128000000, so &+r2 would be 128 + 14 * 2 = 156, making it have the RGB value of 156000000)

I won't be posting the code this time, but the added section basically detects first if the code is this variation of the colour codes, then captures the base colour and the amount of colour darkening/lightening.
Since this variation of colour codes uses ANSI colours as its base, I set up a system which identifies each colour as a three digit number and brightness, indicating which prime colour the RGB number should contain, and what's the actual value of the number. For example, the bright colour RED would have a correspounding value in another string vriable which is "100255"; it has a value at the RED (### = RGB; 1 for R, 0 for G and B) position in an RGB number, and the value is 255, essentially saying the complete code is "255000000".
The script then takes the base brightness value, add or subtract from it depending on which operation is stated by the original code, then apply it in to Kjtar's number-to-hex alias.

Using the system descriped above, the script decides if it should return in to the number-to-hex alias 000 or the actual colour value for each of three valuables the alias takes, returning me an accurate hex RGB value which I can then substitue back in to the processedLine valueable.

Confused yet?

I'd write more, but I have to leave the house in a few minutes, so I will leave it at that.

- This signature intentionally blank -
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