Created
February 22, 2014 16:52
-
-
Save BaldarSilveraxe/9157932 to your computer and use it in GitHub Desktop.
Faking
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on("chat:message", function(msg) { | |
// This assumes that you type something like "!fudge 20:+3:7" | |
// which would pretend that a d20 rolled a 7 for a total of 10. | |
if(msg.type == "api" && msg.content.indexOf("!fudge ") !== -1) { | |
var parts = msg.content.replace("!fudge ", "").split(":"); | |
var faces = parts[0]; | |
var modifier = parts[1]; | |
var value = parts[2]; | |
var total = eval(value + modifier); | |
var color="black" | |
if (value == "1") { | |
color="#730505"; | |
} | |
if (value == faces) { | |
color="#247305"; | |
} | |
var formulaStyle = "font-size:inherit;display:inline;padding:4px;background:white;border-radius:3px;"; | |
var totalStyle = formulaStyle; | |
totalStyle += "border:1px solid #d1d1d1;cursor:move;font-size:1.4em;font-weight:bold;color:black;line-height:2.0em;"; | |
formulaStyle += "border:1px solid #d1d1d1;font-size:1.1em;line-height:2.0em;word-wrap:break-word;"; | |
var clearStyle = "clear:both"; | |
var formattedFormulaStyle = "display:block;float:left;"; | |
var dicegroupingStyle = "display:inline;margin-right:-4px;"; | |
var uisortableStyle = "cursor:move"; | |
var dicerollStyle = "display:inline-block;font-size:1.2em;font-family:san-sarif" + faces; | |
var diconStyle = "display:inline-block;min-width:30px;text-align:center;position:relative"; | |
var didrollStyle = "text-shadow:-1px -1px 1px #fff,1px -1px 1px #fff,-1px 1px 1px #fff,1px 1px 1px #fff;z-index:2;position:relative;color:"+color+";height:30px;min-height:29px;margin-top:-3px;top:0;text-align:center;font size=16px;font-family:sans-serif;"; | |
var backingStyle = "position:absolute;top:-2px;left:0;width:100%;text-align:center;font-size:30px;color:#8fb1d9;text-shadow:0 0 3px #8fb1d9;opacity:.75;pointer-events:none;z-index:1"; | |
var rolledStyle = "cursor:move;font-weight:bold;color:black;font-size:1.3em"; | |
var uidraggableStyle = "cursor:move"; | |
var html = "<div style=\"" + formulaStyle + "\"> rolling 1d" + faces + modifier + " </div>"; | |
html += "<div style=\"" + clearStyle + "\"></div>"; | |
html += "<div style=\"" + formulaStyle + ";" + formattedFormulaStyle + "\">"; | |
html += " <div style=\"" + dicegroupingStyle + ";" + uisortableStyle + "\" data-groupindex=\"0\">"; | |
html += " (<div data-origindex=\"0\" style=\"" + dicerollStyle + "\" class=\"diceroll d" + faces + "\">"; | |
html += " <div style=\"" + diconStyle + "\">"; | |
html += " <div class=\"backing\"></div>" | |
html += " <div style=\"" + didrollStyle + "\">" | |
if ((value=="1")||(value==faces)){ | |
html+= "<strong>" | |
} | |
html += value + "</strong></div>"; | |
html += " <div style=\"" + backingStyle + "\"></div>"; | |
html += " </div>"; | |
html += " </div>)"; | |
html += " </div>"; | |
html += modifier; | |
html += "</div>"; | |
html += "<div style=\"" + clearStyle + "\"></div><strong> = </strong><div style=\"" + totalStyle + ";" + uidraggableStyle + "\"><strong><font size=\"6\"> " + total + "</strong> </div>"; | |
sendChat(msg.who, "/direct " + html); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment