All pastes #328987 Raw Edit

Stuff

public text v1 · immutable
#328987 ·published 2007-01-26 07:38 UTC
rendered paste body
use Xchat qw( :all );

Xchat::register( "Dice", "0.1", "Dice and D&D stats roller");

Xchat::hook_command( "dice", dice, { help_text => "\002Usage:\002 dice xdn\n".
                                                  "       where x is the number 
of dice to roll and n is the sides each dice has" } );
sub dice { 
  my $stuff = $_[0][1];    
  if ($stuff !~ /\d+d\d+/) { Xchat::print("\002Usage:\002 dice xdn\n". "       w
here x is the number of dice to roll and n is the sides each dice has"); } else 
{
    @dinfo = split /d/,$stuff;
    my $roll;
    for (my $i = 0; $i < @dinfo[0]; $i++) {
      $roll .= int(rand($dinfo[1]))+1;
      $roll .= " ";
    };
    Xchat::command("say I just rolled ${stuff}, I got: $roll");
  }
}