mIRC Home    About    Download    Register    News    Help

Print Thread
#106010 23/12/04 04:10 AM
Joined: Dec 2004
Posts: 8
K
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
K
Joined: Dec 2004
Posts: 8
I'm trying to make a script that replaces my messages (input) with randomly colored letters. So far, all i've managed to get is

on *:input:*:{
if ($1 == !on) { set %lol on }
if ($1 == !off) { set %lol off }
if (( %lol == on ) && (/* !iswm $1)) {
set %cruddyness $replacecs($1-,a, $+ $rand(1,14) $+ a,b, $+ $rand(1,14) $+ b, etc, etc, (all the lowercase letters)
set %cruddyness $replacecs(%cruddyness,A, $+ $rand(1,14) $+ A,B, $+ $rand(1,14) $+ B, etc, (all the uppercase letters)
say %cruddyness
halt
}
}

IS there any way to cut the script down because having A, $+ $rand(1,14) $+ A for 52 letters, 10 numbers and a multitude of symbols seems like overkill. Aslo, is there any way to cut the number 8 out of the random identifier while keeping all the numbers above and below it?

Last edited by KaiHeilos; 23/12/04 04:12 AM.
#106011 23/12/04 07:59 AM
Joined: Aug 2003
Posts: 314
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Aug 2003
Posts: 314
Do you want each character to be of a specific color (such as all 'a's are red, all 'b's are green etc.) or can they be independent of each other? For the first, you could loop through characters that haven't yet been colored and replace them:

Code:
alias rn return  $+ $base($calc((8+$r(1,15))% 16),10,10,2)

alias style1 {
  var %i = 1,%s
  while (%i < 10) {
    %s = %s , %i , $rn $+ %i
    inc %i
  }
  set -ln %o $replacex($1 [ %s ] )
  while ($regex(a,%o,/(?<!\d\d)([^\d])/)) %o = $replacecs(%o,$regml(a,1),$rn $+ $regml(a,1))
  return %o
}


Then use $style1(text) to return the formatted text. It assumes that the input text doesn't already contain color since the color codes will be ignored when replacing. $rn is an alias you can use for convenience sake, to return a color code/number combination that isn't yellow

If instead you want to replace each character independently you could use a simple loop:

Code:
alias style2 {
  var %i = $len($1),%o
  while (%i) {
    %o = $+($rn,$mid($1,%i,1),%o)
    dec %i
  }
  return %o
}


Note it uses the same $rn custom identifier mentioned previously

#106012 23/12/04 05:39 PM
Joined: Dec 2004
Posts: 8
K
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
K
Joined: Dec 2004
Posts: 8
The style 1 alias worked great. thanx for that ^_^ How would i remove colors from the script, if at all possible. 0, 8 and 15 are somewhat hard to read so it would help those reading my text if these colors could be removed.

Last edited by KaiHeilos; 23/12/04 05:47 PM.
#106013 23/12/04 05:47 PM
Joined: Aug 2003
Posts: 314
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Aug 2003
Posts: 314
Change the $rn alias slightly:

Code:
alias rn return  $+ $gettok(00 02 03 04 05 06 07 09 10 11 12 13 14,$r(1,13),32)

#106014 23/12/04 05:49 PM
Joined: Dec 2004
Posts: 8
K
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
K
Joined: Dec 2004
Posts: 8
Thanx Sigh. It works great ^_^ A billion praises for you


Link Copied to Clipboard