Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including rpgdice with all npm packages installed. Try it out:

var rpgdice = require("rpgdice")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

rpgdice v0.2.0

Simple eventful dice for rpg or any dicegame


by: ok 2012

Simple eventful dice for rpg or any dicegame.

Designed to support multiple games and players using the same dice, for example in multiple rooms.


Install the module: npm install rpgdice

Require the module: var dice = require('rpgdice');

Roll the dice: dice.roll('1d6+4', 'player1', 'game1')

  • the dice must be in the form of rolls d sides
  • the modifier (+4 etc.), the playername and the gamename can be omitted*


dice.on(' event ', function ( args ) {});

'rolling', dice, roller, game

when a player rolls

  • dice string
  • roller string
  • game string

'roll', roll, roller, game

when a single dice rolls

  • roll string
  • roller string
  • game string

'result', dice, rolls, result, roller, game

when all the dice have been rolled

  • dice string
  • rolls array
  • result number
  • roller string
  • game string

'misroll', error, roller, game

if the dice was malformed or other errors occur

  • error error
  • roller string
  • game string




RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free