mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Dec 2002
Posts: 204
K
keeker Offline OP
Fjord artisan
OP Offline
Fjord artisan
K
Joined: Dec 2002
Posts: 204
I am trying to help some one with the code for a nick decorator type thing, and i have absolutly no idea what i am doing. The code is below abd most of it is his, i just made a few adjustments to what i KNEW was wrong. Reds Mine, blue is his

Code:
 [color:blue]menu nicklist,chat {
  colorful nicks
  .hiya:/me says hiya 
  [color:red].ColorNick:me tells $colornick($snick) look your in color!!
}

[color:blue]alias colornick {
  set %bwnick $snick 
  set %nlength $len(%bwnick)
  unset %cnick
  var %x = 1
  while ([color:red]%x <= %nlength[color:blue]) {
    set %n $mid(%bwnick,%x,1)
    :again
    set %fg $rand(0,15)
    set %bg $rand(0,15)
    if (%fg == %bg) goto again
    set %cnick  $+ %fg $+ , $+ %bg $+ %n
    inc %x
  }

  return %cnick
}
[/color]
[/color]
[/color]
[/color]
[/color]

he wants it so it colors each and every letter a random color. Like i said i have absolutly no idea what i am doing, so i am asking for help. If Any one could show me what to do, that would be greatly appreciated

thanks




keek: Scots - intr.v. keeked, keekĀ·ing, keeks
To peek; peep.
Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
Code:
alias colornick {
  var %l = 1
  while ($mid($1-, %l, 1) != $null) {
    var %c = $rand(0,15)
    while (%c == $color(background)) { var %c = $rand(0,15) }
    var %name = $+(%name,,%c,$mid($1-, %l, 1))
    /inc %l
  }
  return $+(%name,)
}

I even added protection against matching a random color with the background one. If you don't want it, remove the "while (%c == $color(background))" line


-KingTomato
Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
here is an even better method...

Code:
alias colornick {
  var %l = 1
  while ($mid($1-, %l, 1) != $null) {
    if ($prop == bg) {
      var %c = $rand(1,15), %bg = $rand(1,15)
      while (%bg == %c) var %bg = $rand(1,15)
      var %name = $+(%name,,%c,$chr(44),%bg,,$mid($1-, %l, 1))
    }
    else {
      var %c = $rand(0,15)
      while (%c == $color(background)) { var %c = $rand(0,15) }
      var %name = $+(%name,,%c,,$mid($1-, %l, 1))
    } 
    /inc %l
  }
  return $+(%name,)
}

This will do $colornick(name) and make it all colors (avoiding the background one), or u can add .bg ($colornick(name).bg) and it will include background colors.


-KingTomato
Joined: Aug 2003
Posts: 1,831
I
Hoopy frood
Offline
Hoopy frood
I
Joined: Aug 2003
Posts: 1,831
This won't screw up if the nick contains numbers.
Code:
alias colornick {
  var %i = 1,%a = $remtok(00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15,$color(b).dd,32)
  while $mid($$1,%i,1) != $null {
    var %r = $+(%r,,$gettok(%a,$r(1,15),32),$ifmatch)
    inc %i
  }
  return %r $+ 
}

Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
mine doesn't anyways, I added a double bold before each letter.


-KingTomato
Joined: Aug 2003
Posts: 1,831
I
Hoopy frood
Offline
Hoopy frood
I
Joined: Aug 2003
Posts: 1,831
Well, the second (which goes beyond what OP asked for) doesn't, but using 3x the ^codes is not such a great idea. wink

(You also could use $base(N,10,10,2) to avoid so many control codes.)

Joined: Dec 2002
Posts: 204
K
keeker Offline OP
Fjord artisan
OP Offline
Fjord artisan
K
Joined: Dec 2002
Posts: 204
ty kingtomato it works perfect


keek: Scots - intr.v. keeked, keekĀ·ing, keeks
To peek; peep.
Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
it's only for a nickname, so he control code count wasn't really a concern for me. I just did it fast'n'dirty. >:P

np keeker


-KingTomato
Joined: Aug 2003
Posts: 1,831
I
Hoopy frood
Offline
Hoopy frood
I
Joined: Aug 2003
Posts: 1,831
Quote:
it's only for a nickname, so he control code count wasn't really a concern for me

It should be, if the nick is 15 chars long (and they can be twice that length on some networks), your script adds 46 control codes to that word alone.


Link Copied to Clipboard