|
flipwon Beginner
Joined: 09 May 2008 Posts: 10
|
Posted: 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? |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: 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. |
|
|
|
flipwon Beginner
Joined: 09 May 2008 Posts: 10
|
Posted: Fri May 16, 2008 7:09 pm |
hmmm all that did was make the word repeat four times lol
rainbowrainbowrainbowrainbow :P |
|
|
|
flipwon Beginner
Joined: 09 May 2008 Posts: 10
|
Posted: 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.. |
|
|
|
|
|
|
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
|
|