Noltar's Dice Roller

A dice rolling command that lets you specify the number of dice, and various sided dice.

Author: Noltar@M*U*S*H
Category: Games
Commands: @create, @emit, @lock, @lset, @set.
Features: regexp commands.
Compatibility: CobraMUSH, PennMUSH.

Instructions

Copy and paste the below code into a compatible MUSH or MUX.

MUSHCode for Noltar's Dice Roller

@create Dice Roller
@lock Dice Roller==me
@set Dice Roller=!NO_COMMAND
@lset Dice Roller/Parent=no_inherit
@set Dice Roller = LINK_OK
@set Dice Roller = VISUAL
&CMD_ROLL Dice Roller=$^roll ([0-9]*)d(100|20|12|10|8|6|4|3|2)(\+|-)?([0-9]*)?$:@emit %N rolls [rest(%0)] and gets: [[switch(%3,-,sub,add)]([die(%1,%2)],%4)]
@set Dice Roller/CMD_ROLL=regexp
&CMD_SROLL Dice Roller=$^sroll ([0-9]*)d(100|20|12|10|8|6|4|3|2)(\+|-)?([0-9]*)?$:@emit %N rolls [rest(%0)] and gets [setr(0,die(%1,%2,1))] for a total of: [[switch(%3,-,sub,add)]([lmath(add,%q0)],%4)]
@set Dice Roller/CMD_SROLL=regexp
&DESCRIBE Dice Roller=%rThis is a simple dice roller. It supports the following syntax:%r%r[ljust(roll 1d4,15)]<- rolls one four-sided die%r[ljust(roll 3d6,15)]<- rolls three six-sided dice%r[ljust(roll 3d12+4,15)]<- rolls three twelve sided dice and adds four to the total%r[ljust(roll 2d100-17,15)]<- rolls two one hundred sided dice and subtracts 17 from the total%r[ljust(sroll 3d12,15)]<- rolls three twelve-sided dice and shows the separate die results as well as the total%r%rThe dice supported by this system are: 3, 4, 6, 8, 10, 12, 20, and 100 sided dice.
@set Dice Roller/DESCRIBE=no_command visual prefixmatch public nearby

look Dice Roller