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
Lalaynya
Wanderer


Joined: 23 Aug 2002
Posts: 96

PostPosted: Tue Apr 22, 2003 1:07 am   

Help with a coloring script.
 
Ok, I messed with this forever the other day, and couldn't come up with a way that worked.

What I'm trying to do is set up a way to give a string a certain color sequence...

Say I have something like this: xxxxx

I want to be able to enter something longer, and have it colored with the same pattern... so:
xxxxxxxxxxxxxxx


What I tried was to set up a string list variable with the color code to add for each section, and a second string list with the percentage that it started at.

then I looped through the string, one letter at a time, checking what %of the way through it was, comparing that with the second string list and using #SENDP to send the appropriate color code(from the first string list) and letter.

I just couldn't get the damn thing to work!!!!

The reason I was trying to set it in string lists is that I could then easily change the color scheme I was using, or maybe even pick from a list of color schemes.

HELP!
Reply with quote
TonDiening
GURU


Joined: 26 Jul 2001
Posts: 1958
Location: Canada

PostPosted: Tue Apr 22, 2003 6:06 am   
 
Conceptual:
#VAR s {12345}
#VAR ColorBreak ""
#VAR ColorCodes {&b|&m|&y|&r|&g}
#LOOP %numitems( @ColorCodes) {#ADDITEM ColorBreak %eval( 1+(%i-1)*%len( @s)/%numitems( @ColorCodes))}
#VAR sc ""
#LOOP %numitems( @ColorCodes) {#VAR sc %concat( @sc, %item( @ColorCodes, %i), %copy( @s, %item( @ColorBreak, %i), %eval( %if( %i<%numitems( @ColorCodes), %item( @ColorBreak, %i+1), %len( @s+1))-%item( @ColorBreak, %i))))}
#SH @s vs @sc

There might be a way to play with mod to make it less hacked up. Couldn't think of a way to figure out the off length strings.



Ton Diening
Reply with quote
AzCowboy
Adept


Joined: 09 Nov 2000
Posts: 222
Location: USA

PostPosted: Tue Apr 22, 2003 8:10 am   
 
Couldn't get it to work with the variables, since one of the color codes I need is `@ ... so I hacked it up and used #sendp and got it working.

Thanks, Ton!
Reply with quote
Lalaynya
Wanderer


Joined: 23 Aug 2002
Posts: 96

PostPosted: Tue Apr 22, 2003 4:48 pm   
 
Grrr... *kills her hubby for leaving HIS account logged in*


Thanks again, Ton... It's not as pretty as I'd like it(due to my lousy coding!) but it works, and that's what's important, right?
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