|
oldguy2 Wizard
Joined: 17 Jun 2006 Posts: 1201
|
Posted: Mon Apr 13, 2009 8:53 pm
Simple way to color a line of text random colors |
Code: |
$list = "mxpyellow|mxpgold|mxporange"
$count = %len(%line)
#loop 0,$count {#pcol %item($list,%random(1,%numitems($list))) %i} |
I looked around for something like this but didn't see anything but old outdated stuff or stuff that used aliases.
This one gives the trigger line the effect of fire text. You can put whatever colors you want in $list. |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4692 Location: Pensacola, FL, USA
|
Posted: Mon Apr 13, 2009 9:56 pm |
We need a finished scripts folder in CMUD i think, i rather like this.
|
|
_________________ Discord: Shalimarwildcat |
|
|
|
charneus Wizard
Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Tue Apr 14, 2009 12:44 am |
shalimar wrote: |
We need a finished scripts folder in CMUD i think, i rather like this. |
What do you think the package library is for? :P
Charneus |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4692 Location: Pensacola, FL, USA
|
Posted: Tue Apr 14, 2009 4:04 am |
the package library is for the more complex scripts with more than one setting involved
|
|
_________________ Discord: Shalimarwildcat |
|
|
|
charneus Wizard
Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Tue Apr 14, 2009 5:18 am |
Not necessarily. There are some in there that only have a few settings. The package library is a place to share scripts you have written. You're not going to get yelled at if you put one or two settings in it. :P Besides, you can always add to it as you come up with more settings.
Charneus |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4692 Location: Pensacola, FL, USA
|
Posted: Tue Apr 14, 2009 8:52 am |
Either way, its a nice lil snippet there.
Any ny chance you could get this to trigger off a pattern of: ({@list})
But only color %1? |
|
_________________ Discord: Shalimarwildcat |
|
|
|
oldguy2 Wizard
Joined: 17 Jun 2006 Posts: 1201
|
Posted: Tue Apr 14, 2009 12:29 pm |
Well you can but I'm not sure how to stop it at the end of the range. It would be nice if #pcol worked that way or there were another command to just color that range specifically in the string or a single character at an index position. You would have to recolor the line back to the original color after the %1 part.
Like this string of text as a trigger:
This is some trigger text to color (these words) random colors.
If you use the following:
Code: |
$list = "mxpyellow|mxpgold|mxporange"
$words = %1
$pos = %pos( $words, %line)
$start = ($pos - 1)
$end = ($start + %len( $words))
#loop $start,$end {#pcol %item( $list, %random( 1, %numitems( $list))) %i} |
It will randomly color the characters in %1 but after %1 whatever the next color in $list ends up being the color of the rest of the string.
So adding for example:
Code: |
#pcol mxpsilver ($end+1) |
To the end of the script will color the rest of the line back to silver or whatever color you need and leaving only %1 randomly colored.
Maybe someone else knows a better way.
So I guess you could use this function:
Code: |
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
<func name="fireText" copy="yes">
<value>$list = "mxpyellow|mxpgold|mxporange"
$pos = %pos( $words, $string)
$start = ($pos - 1)
$end = ($start + %len( $words))
#loop $start,$end {#pcol %item( $list, %random( 1, %numitems( $list))) %i}
#pcol $color ($end+1)</value>
<arglist>$words,$string,$color</arglist>
</func>
</cmud>
|
Then in your trigger just put:
Code: |
#call @fireText( %1, %line, "mxpsilver") |
Of course put whatever the original color is.
Really you could make various functions like that for different effects or add another parameter and just pass the $list of colors you want and change the function name to whatever. |
|
|
|
|
|