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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Haldrik
Wanderer


Joined: 03 Sep 2007
Posts: 88

PostPosted: Wed Oct 08, 2008 2:48 am   

Advanced Colors? Splitting a pattern into multiple colors.
 
I've been thinking of ways to make my mud life more colorfull... I've been limited mostly to #color, #cw, #ansi and a limited amount of MXP.

What I've been thinking of is a way to highlight a single trigger into multiple colors.

I.e.

#trigger {Kill}

Would come out like this...

Kill

Or something of this nature.

Grass

Fire

Thanks guys!!

I was also thinking if it got terribly complicated if i could write a nice function to perhaps make it a bit easier...

Any help is greatly appreciated!!
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Wed Oct 08, 2008 4:49 am   
 
Well you have a couple of options...

If you already know the words you want to color, you can set up color substitutions for those words...

You can break up the pattern for the word you want to match and color each piece independently
Code:
 #trigger {(ki)(ll)} {%ansi(red)%1%ansi(white)%2}


The third is you can make a function that colors each letter of a word differently. The %len(s), %ansi() and %char(i) should help with that.

Finally you could do a 26 triggers (one for each letter) and assign a color to each letter.

They each have various performance implications but those are the options.
_________________
Asati di tempari!
Reply with quote
Haldrik
Wanderer


Joined: 03 Sep 2007
Posts: 88

PostPosted: Wed Oct 08, 2008 6:00 am   
 
Great!!

I'm really liking the first option. It gives me a ton of options and what... 99 variations ?:P

The third option ? A bit extreme I think... althought i suppose it might be fun to see what the world would look like.... maybe i could randomize it.


What are the differing performance implications between the first and second option? If the first takes up less memory and processing etc, i would be WAY more inclined to head that route, instead of learning to create option 2?


Thanks tech! :)
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Wed Oct 08, 2008 2:49 pm   
 
Option 1 should perform slightly better. and should be a little cleaner. You should be able to use a database variable to do predefine your substitutions and make it easier to maintain.

Something along the lines of the following should help.

Code:
#TRIGGER {(%dbkeys(@ColorWords)} {#PSUB {%db(@ColorWords,%1)}}


It may be buggy since it's off the top of my head, but should give you the general idea.

Edit by Fang: typo in a function name.
_________________
Asati di tempari!
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD 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