Sephiroth
http://sephiroth.scifi-action.de/board/

/mixit
http://sephiroth.scifi-action.de/board/viewtopic.php?f=4&t=81
Seite 1 von 1

Autor:  Sephiroth [ 10. August 2008 12:49 ]
Betreff des Beitrags:  /mixit

; Adds some colors! ;)
; Usage: /mixit <text>
; Usage: $mixit(<text to convert>)
; Param: $mixit(<text>)[.rand|.mix]
; Update:
; - Fixed a bug with numbers/specials chars
alias mixit {
  !var %out,%t,%c,%c1,%c2,%c3,%c4,%c5,%i,%x,%u,%text,%len,%conv,%upper,%lower,%cu,%iclass,%last,%li,%new,%numbers,%special,%dontignorespace
  ; b for bold
  ; u for underlined
  ; r for reversed
  ; e. g. %upper = bu
  %upper = bu
  %lower = u
  %special = b
  %numbers = b

  ; Counts space as "last normal char and converts the LOWER CASE text to the "fellower"
  %dontignorespace = $true
  if ($prop == rand) {
    %t = r
    ; no need to change!
    %c1 = $r(0,15)
    %c2 = $r(0,15)
    %c3 = $r(0,15)
    %c4 = $r(0,15)
    %c5 = $r(0,15)
  }
  elseif ($prop == mix) {
    %t = m
    ; NEVER REALLY NEVER CHANGE THIS! :P
    ; (maybe the 2nd number inside the $r()
    ; if Khaled adds more than just 16 colors)
    %c = $!r(0,15)
  }
  else {
    %t = n
    ; Uppercase
    %c1 = 12
    ; First char after uppercase
    %c2 = 3
    ; Lowercase
    %c3 = 7
    ; Special chars
    %c4 = 13
    ; Numbers
    %c5 = 10
  }
  %text = $strip($replace($1-,$chr(32),$chr(160)))
  %len = $len(%text)
  %conv = $false
  ; Lets start a run ;)
  %x = 0
  while (%x < %len) {
    inc %x
    ; current char
    %i = $mid(%text,%x,1)
    ; changing the colors
    if (%t == m) {
      %u = $eval(%c,2)
      %c1 = $chr(3) $+ $base(%u,10,10,2)
      %c2 = $chr(3) $+ $base(%u,10,10,2)
      %c3 = $chr(3) $+ $base(%u,10,10,2)
      %c4 = $chr(3) $+ $base(%u,10,10,2)
      %c5 = $chr(3) $+ $base(%u,10,10,2)
    }
    elseif (!%conv) {
      %conv = $true
      %c1 = $chr(3) $+ $base(%c1,10,10,2)
      %c2 = $chr(3) $+ $base(%c2,10,10,2)
      %c3 = $chr(3) $+ $base(%c3,10,10,2)
      %c4 = $chr(3) $+ $base(%c4,10,10,2)
      %c5 = $chr(3) $+ $base(%c5,10,10,2)
    }
    %iclass = ""
    if ($len(%real)) {
      %li = %real
      !unset %real
    }
    ; color tag builder starts here
    if (%i islower) && (%i isalpha) {
      if (%li isupper) {
        %iclass = %c2
      }
      else {
        %iclass = %c3
      }
      %iclass = %iclass $+ $bur(%lower)
    }
    elseif (%i isupper) && (%i isalpha) {
      %iclass = %c1
      %iclass = %iclass $+ $bur(%upper)
    }
    elseif (%i isnum) {
      %iclass = %c5
      %iclass = %iclass $+ $bur(%numbers)
    }
    elseif (%i != $chr(160)) {
      %iclass = %c4
      %iclass = %iclass $+ $bur(%special)
    }
    elseif ((%i == $chr(160)) && (!%dontignorespace)) {
      %iclass = %last
      !var %real = %li
    }
    if (%last != %iclass) {
      %last = %iclass
      %new = $chr(15) $+ %iclass $+ %i
    }
    else {
      %new = %i
    }
    if (!$len(%real)) {
      %li = %i
    }
    %out = %out $+ %new

  }
  %out = $replace(%out,$chr(160),$chr(32))
  if ($len(%out)) {
    if ($isid) {
      !return %out
    }
    else {
      ; the reason why i don't use !say here is that i have a custom say alias which splits the text after 420 chars
      say %out
    }
  }
}
alias -l bur {
  !var %c = $1,%r
  if ($c(%c).b) { %r = %r $+ $chr(2) }
  if ($c(%c).u) { %r = %r $+ $chr(31) }
  if ($c(%c).r) { %r = %r $+ $chr(22) }
  !return %r
}
alias -l c { if ($prop isincs $1) { !return $true } | !return $false }

Seite 1 von 1 Alle Zeiten sind UTC + 1 Stunde
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/