Guest User

Untitled

a guest
Apr 21st, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.05 KB | None | 0 0
  1. sub colsure {
  2.     my $type = shift ;; my %magic;
  3.     # this used to be much more complex (weechat's fault) but now it is has been dumbed down enough to deserve a rewrite sometime soon
  4.     return sub {
  5.         my @colour = map { ($_ ~~ undef) ? return : $_ } @_;
  6.         if ($type eq 'magic') {
  7.             if (($#colour + 1) == 2) {
  8.                 return $magic{"@colour"} if $magic{"@colour"};
  9.                 $magic{"@colour"} = "".int(rand 15).",".int(rand 15);
  10.                 return $magic{"@colour"}
  11.             }
  12.             else {
  13.                 return $magic{"@colour"} if $magic{"@colour"};
  14.                 $magic{"@colour"} = "".int(rand 15);
  15.                 return $magic{"@colour"}
  16.             }
  17.         }
  18.         elsif ($type eq 'random') {
  19.             if (($#colour + 1) == 2) { return "".int(rand 15).",".int(rand 15) }
  20.             else { return "".int(rand 15) }
  21.         }
  22.         else {
  23.             if (($#colour + 1) == 2) { return "0$colour[0],$colour[1]" }
  24.             else { return "$colour[0]" }
  25.         }
  26.     }
  27. }
Add Comment
Please, Sign In to add comment