All pastes #1509855 Raw Edit

Chatzilla roll script

public javascript v1 · immutable
#1509855 ·published 2009-07-28 11:04 UTC
rendered paste body
plugin.id = "roll";plugin.minor = 1;plugin.major = 0;plugin.version = plugin.major + "." + plugin.minor;plugin.description = 'Adds /roll command';plugin.init = function initPlugin (obj) {    plugin.cmdary = [        [ "roll", cmdRoll, null, "<dice> <faces>" ]    ];    client.commandManager.defineCommands(plugin.cmdary);    function cmdRoll (e) {        var dice = parseInt(e.dice, 10) || 1;        var faces = parseInt(e.faces, 10) || 1;        var results = [];        while (results.length < dice) {            results.push(Math.floor(Math.random() * faces + 1));        }        var message = "rolls " + dice + "d" + faces + ": " + results.join(" + ") + " = " + results.reduce(function (prev, curr, i, a) { return prev + curr; }, 0);        dispatch('me', { "action": message });    }};plugin.disable = function () { };plugin.enable = function () { };