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


Joined: 09 May 2008
Posts: 10

PostPosted: Fri May 16, 2008 6:51 pm   

Coloring a word
 
I don't know if this is possible, but, i want to be able to color a word (obviously client side) but with all different colors
for example
rainbow
i want to be able to color each letter, client side, a random color, IE R being red, A being green, I being blue, blah blah blah
but ONLY if it has another word in front of it

big rainbow (the word rainbow is colored)
blahblahblah rainbow (the word isn't colored)

so basically, color the word, multiple colors, only if it has the word big in front of it... is that possible?
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Fri May 16, 2008 6:59 pm   
 
You're going to want a function that returns a random colour name when called, say @RandomColour().

#function RandomColour {%case(%random,"blue","green","red")}

Make the list as long or as short as you like. Then, you create another function that returns whatever string it's given, with each letter given a colour:

#function ColourString {%subregex(%1,"(.)",%concat("<color ",@RandomColour,">",%1,"</color>")}

(NB: I can't remember what the proper syntax is for the matches in the subregex's regex. In cmud, it was %pat(1) and more recently, \1, but I seem to remember it being %x1 in the past. The help file says %1 is correct, though, and I shan't argue.)

Finally, you create a trigger for whatever you want, and plug in your code to return the new string:

#trig {big rainbow} {#sub {big @ColourString("rainbow")}}

I haven't tested this, because I don't have zMUD installed, but I've tested the concept in CMUD and know it's sound.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
flipwon
Beginner


Joined: 09 May 2008
Posts: 10

PostPosted: Fri May 16, 2008 7:09 pm   
 
hmmm all that did was make the word repeat four times lol


rainbowrainbowrainbowrainbow :P
Reply with quote
flipwon
Beginner


Joined: 09 May 2008
Posts: 10

PostPosted: Fri May 16, 2008 7:14 pm   
 
how would i just color the word one solid color
IE big rainbow
color rainbow blue
only following the big though, and only being the word rainbow..
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