$colortext(Color list,text,bur)
-Color list is a list of color codes separated by spaces such as those used in the example aliases below, rainbow and colorize.
-Text is the text to be modified (shockingly)
-bur are optional parameters for bold, underline, and reverse text
**Note that if you want to use color codes with commas you must first set them as a variable and pass the variable as the 1st parameter rather than the numbers themselves.
Thanks to Kirby and jonesy44 for the explode alias!
I tested these pretty extensively but if you find a bug please let me know.
Two example aliases are included for use with the identifier as well, enjoy!
/*
$colortext(Color list,text,bur) by tv3636
-Color list is a list of color codes separated by spaces such as those used in the example aliases below, rainbow and colorize.
-Text is the text to be modified (shockingly)
-bur are optional parameters for bold, underline, and reverse text
**Note that if you want to use color codes with commas you must first set them as a variable and pass the variable as the 1st parameter rather than the numbers themselves.
Thanks to Kirby and jonesy44 for the explode alias!
*/
alias colortext {
var %y = 1
var %cols = $1
var %colscount = $r(1,10)
while (%y <= $numtok($2,32)) {
var %text = $explode($gettok($2,%y,32),32)
var %x = 1
while (%x <= $numtok(%text,32)) {
var %out = %out $+ $+ $gettok(%cols,%colscount,32) $+ $gettok(%text,%x,32) $+
inc %colscount | inc %x
if (%colscount > $numtok($1,32)) %colscount = 1
}
%out = %out $+ $chr(160)
inc %y
}
return $replace($3,b,,u,,r,) $+ $left(%out,-1)
}
alias explode { var %x $2 | return $regsubex($1,/(.)/g,$+(\1,$chr(%x))) }
;Example aliases using $colortext()
alias rainbow { msg $active $colortext(04 13 06 12 10 11 09 08 07 05,$1-,b) }
alias colorize { var %cols = 04,06 07,04 08,07 09,08 12,09 13,12 06,13 04,06 07,04 08,07 09,08 12,09 13,12 06,13 | msg $active $colortext(%cols,$1-,b) }
:/ Well as I said I don't know any regex. I guess this is pretty useless and way too long then. Oh well. The one thing that doesn't do is keep an order of the colors so that it looks nicer and avoids colors that are unwanted (although I'm sure there's some regex magic that could accomplish that in like 4 characters)
hi
sorry i don't speak verry well english
why all that code for mixed color of line text??
u can only do that
alias colortext return $replace($2,b,,u,,r,) $+ $regsubex($1,/()/g,$chr(3) $+ $r(1,15) $+ \1)
for test use
//echo -a $colortext(just for test,bur)
or
alias testcolor echo -a $colortext($1-,bur)
/testcolor just for test
Alright, sounds good. I don't know anything about regex haha. And that alias was posted by jonesy44 by the way.
http://www.hawkee.com/snippet/6008/