This dice roller lets you decide how many dice to roll, and how many sides on each die. If no parameters are specified, it defaults to one 6-sided die. To use it, use the following format: !roll . For example, !roll 10 20 would roll 10 dice, each having twenty sides. It then totals the amounts and gives you the average. Have fun!
on *:TEXT:!roll*:#: {
if ($2- == $null) {
set %dice 1
set %sides 6
%roll = $rand(1,%sides)
msg # Roll 1: %roll
}
else {
set %dice $2
set %sides $3
set %i 0
set %total 0
set %average 0
if ($2 !isnum) || ($3 !isnum) {
msg # INVALID PARAMETERS!
halt
}
if (%dice <= 0) || %sides <= 0) {
msg # INVALID PARAMETERS!
halt
}
while (%i < %dice) {
inc %i 1
%roll = $rand(1,%sides)
msg # Roll %i $+ : %roll
%total = $calc(%total + %roll)
}
msg # Total: %total
%average = $calc(%total / %dice)
msg # Average: %average
}
}