All pastes #1371279 Raw Edit

terroll.ini

public text v1 · immutable
#1371279 ·published 2009-03-25 03:57 UTC
rendered paste body
on 1:text:!thelp*:#:{
  msg $nick number sides division multiplication addition/subtraction multiplication division
  msg $nick scripted mostly by Teraunce with help from NeonDragon
}

on 1:text:!tr*:#:{
  if (($2 !isnum) || ($3 !isnum) || ($4 !isnum) || ($5 !isnum) || ($6 !isnum) || ($7 !isnum) || ($8 !isnum)) {
    ;msg $chan replacing invalid values and calculating
  }
  else {
    ;msg $chan calculating
  }
  if (($2 == $null) || ($2 <= 0) || ($2 !isnum)) {
    ;msg $chan How many dice? Let's try 1.
    var %dice=1
    ;halt
  }
  else {
    var %dice = $2
  }

  if (($3 == $null) || ($3 <= 0) || ($3 !isnum)) {
    ;msg $chan Let's settle for 20 sides
    %sides = 20
  }
  else {
    %sides = $3
  }

  if (($4 == $null) || ($4 <= 0) || ($4 !isnum)) {
    %div1 = 1
  }
  else {
    %div1 = $4
  }

  if (($5 == $null) || ($5 <= 0) || ($5 !isnum)) {
    %mul1 = 1
  }
  else {
    %mul1 = $5
  }

  if (($6 == $null) || ($6 !isnum)) {
    %add = 0
  }
  else {
    %add = $6
  }

  if (($7 == $null) || ($7 <= 0) || ($7 !isnum)) {
    %div2 = 1
  }
  else {
    %div2 = $7
  }

  if (($8 == $null) || ($8 <= 0) || ($8 !isnum)) {
    %mul2 = 1
  }
  else {
    %mul2 = $8
  }

  var %i = 1, %result = 0
  while (%i <= %dice) {
    %i = %i + 1
    %result = %result + $rand(1,%sides)
  }
  %result2 = $calc((((( %result / %div1 ) * %mul1 ) + %add ) / %div2 ) * %mul2 )
  ;msg _$chan _%result2 = _$calc((((( %result / %div1 ) * %mul1 ) + %add ) / %div2 ) * %mul2 ) debug script
  msg $chan $nick $+ 's roll ( $+ $+(%dice,d,%sides,+,%add) $+ ) $+ : %result2 $9- (unmodified roll was %result $+ )

}