Just a reminder: if you throw 10 6 sided dice (or 1 die 10 times) the sum will indeed be a number between 10 and 60, but it will not be the same as just picking a random number between 10 and 60.
Let's check probabilities for 2 dice:
throwing a 2=1+1: 1/6 * 1/6 = 1/36 chance
throwing a 3=2+1 or 1+2: 2/36 chance
throwing a 4=1+3 or 2+2 or 3+1: 3/36 chance
throwing a 7= 1+6 or 2+5 or 3+3 or 4+2 or 5+2 or 6+1: 6/36 chance
etc
Just choosing a random number between 2 and 12: 1/11 chance for all outcomes...
Here's one that works ok, without needing a text file.
alias dice {
; roll dice, argument is <num_dice> [d <num_faces> [+-*/^ modifier]]
; 2d6 or 2d or just 2 -> roll 2 normal (6 sided) dice
; 5d100-2 -> roll five 100 sided dice and subtract 2
; 1d6^2 -> roll one 6 sided die and square the result
; usage: $dice(3d6*5)
if ($regex($1,/^(\d+)\s*(?:d\s*(?:(\d+)\s*(?:([-+*/^])\s*(\d+))?)?)?$/)) {
var %i = 0, %sum = 0, %sides = $iif($regml(2),$v1,6)
while (%i < $regml(1)) {
inc %sum $rand(1,%sides)
inc %i
}
if ($regml(4)) var %sum = $calc(%sum $regml(3) $regml(4))
return %sum
}
return $false
}
on *:TEXT:!roll:#:describe $chan rolls dice and they land on $dice([color:blue]2d6[/color])
on *:TEXT:!roll *:#:{
if ($dice($2) != $false) describe $chan rolls $2- dice and they land on $v1
else notice $nick Sorry, $2- is not a valid request
}
Change the default to whatever you like, your text file suggests 1d12 since you cannot throw a 1 with 2 normal dice