Hey everyone smile

Can someone please help me with a script which I just tried to make? Im really new to scripting and can't find a solution


What it should do:

- Give all letters and numbers a random color on input
- The colors 0, 1, 2, 3, 5, 14 and 15 should not be chosen
- The same color should not be chosen in the next 3 letters/numbers

My code so far:

Code
alias rand {
  return $rand(0,15)
}

on *:input:#: {
  var %i = 1, %str, %color, %lastColor1 = $null, %lastColor2 = $null, %lastColor3 = $null
  while (%i <= $len($1-)) {
    if ($mid($1-,%i,1) == " ") {
      %str = %str " "
      inc %i
      continue
    }

    %color = $rand(0,15)
    while (%color == 0 || %color == 1 || %color == 2 || %color == 3 || %color == 5 || %color == 14 || %color == 15 || %color == %lastColor1 || %color == %lastColor2 || %color == %lastColor3) {
      %color = $rand(0,15)
    }
    %str = %str $+ $chr(3) $+ %color $+ $mid($1-,%i,1)
    set %lastColor3 %lastColor2
    set %lastColor2 %lastColor1
    set %lastColor1 %color
    inc %i
  }
  msg $chan %str
  halt
}

It works partly. It gives every letter a random color. But it does not display spaces, and when I use numbers in my input, it misses some in output.

Thank you in advance smile