chat prompt command: !mhrroll Copy / Paste text below in Game Settings. Go to Next Post for 3D dice fix. on("chat:message", function(msg) { if(msg.type == "api" && msg.content.indexOf("!mhrroll ") !== -1) { var diceString = msg.content.replace("!mhrroll ", ""); var diceArray = diceString.split(" "); var rolls = []; var rollText = ""; // Roll each dice in the input diceArray.forEach(function(dice) { var parts = dice.split("d"); var numberOfDice = parseInt(parts[0]) || 1; var diceSize = parseInt(parts[1]); for (var i = 0; i < numberOfDice; i++) { var result = randomInteger(diceSize); rolls.push(result); rollText += "d" + diceSize + ": " + result + " "; } }); // Sort and sum the top two rolls rolls.sort(function(a, b) { return b - a }); var total = rolls[0] + (rolls.length > 1 ? rolls[1] : 0); // Output the result sendChat(msg.who, "/em rolls " + rollText + " | Total: " + total); } }); function randomInteger(max) { return Math.floor(Math.random() * max) + 1; }