Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Advertisement Create a free account

Blind Roll script: Possible to parse inline results?

1435074686
So I've been making use of the Blind Roll /Rig Roll script by Aaron Garrett ( HERE ) for quite some time now. It's great because for my play style, having players able to roll their checks and not see the result has become the default way we play, and it made everything better. But recently we were testing some things, and the script is not built to take inline roll inputs or parse them. It breaks things. So I'm just wondering if anyone knows if it's possible to modify the script so that it can handle inline results, and possible be built to parse a text input, and output them cleanly to the DM for the purpose of saving space? I post this as it's own thread because try as I might, I cannot find the script's thread and ask there.
1435092024
It could. You could also use powercards and use the --whisper|GM option. It is effectively a blind roll at that point (I think... I've never actually tested that, lol). There is no rigging of rolls however.
1435092291
Just tested and yes... --whisper|GM in powercards is a blind roll for the player. So something like... !power {{ --name|Skill Check --emote|HoneyBadger makes a stealth check... --Stealth:|[[ 1d20 + 3 [Dex Mod] ]] }} ... is sent to the GM while the emote appears in chat for all the players.
1435094745
I suppose my question was more "Can anyone fix this, because I certainly don't know enough Javascript to do it". I appreciate the nod to powercards, though I don't think I'll be switching to it only because my players are used to and have macros set up for the !blindroll syntax, and I don't want to have to walk them through changing them all. I suppose a more lightweight roll script that handles inline would be better, but again, I certainly can't write it.
1435096436
The Aaron
Forum Champion
API Scripter
Try this. I only adjusted the !blindroll portion, not the !rigroll part. You should be able to do: !blindroll [[@{selected|skill}+1]]d20+[[ [[@{selected|attack]]+@{target|ac} ]] Weird attack.. and get something like: Blind roll sent to GM 3d20+8 Weird attack.. and /gmroll 3d20+8 Weird attack.. from bob Not really sure what else you really want, but it's certainly possible. BTW, I didn't test this, but it's a pretty minor change (so far) and should work fine. /******************************************************************************* * rollers.js - Provides specialized dice rolling alternatives. * * Dependencies: none ******************************************************************************* * * Commands for performing specialty dice rolling. * * !blindroll roll * Players may issue this command to have a roll of the dice generated in * secret to the GM only. This is useful when the player should not know * the result of the roll (e.g., a Stealth check). * * Example: * !blindroll 1d20+7 Stealth check * This example would be rolled as a GM roll so that the results are only * visible to the GM. * * !rigroll &lt;num dice&gt;d&lt;num sides&gt;:&lt;modifier&gt;:&lt;actual rolls (comma-separated)&gt; * Occasionally, a GM may want to exert control over fate and have the dice * fall a certain way (for cinematic reasons or to avoid a TPK). This command * allows a GM to roll "in the open" and still get the desired outcome. * This command cannot currently deal with complex roll types that are * available generally in Roll20. * Whenever this command is issued, the GM also receives a whisper informing * him of the rigged roll. This is favored over simply denying players the * ability to rig rolls because there may be times when the GM and a player * conspire together for story purposes and require a particular outcome. * * Examples: * !rigroll 1d20:+3:18 * !rigroll 5d4:+8:2,3,1,3,4 * The first example would produce a result of 21 (showing that an 18 was * rolled). The second example would also produce a result of 21 (showing * that a 2, 3, 1, 3, and 4 were rolled. * ******************************************************************************* * Copyright (C) 2014 Aaron Garrett (<a href="mailto:aaron.lee.garrett@gmail.com" rel="nofollow">aaron.lee.garrett@gmail.com</a>) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see &lt;<a href="http://www.gnu.org/licenses/" rel="nofollow">http://www.gnu.org/licenses/</a>&gt;. *******************************************************************************/ if(!('contains' in String.prototype)) { String.prototype.contains = function(str, startIndex) { return ''.indexOf.call(this, str, startIndex) !== -1; }; } var inspired = inspired || {}; on("chat:message", function(msg_orig) { var msg=_.clone(msg_orig); if(msg.type != "api") return; if(_.has(msg,'inlinerolls')){ msg.content = _.chain(msg.inlinerolls) .reduce(function(m,v,k){ m['$[['+k+']]']=v.results.total || 0; return m; },{}) .reduce(function(m,v,k){ return m.replace(k,v); },msg.content) .value(); } if(msg.content.contains("!blindroll ")) { var roll = msg.content.replace("!blindroll ", "").trim(); if(roll.length &gt; 0) { sendChat(msg.who, "Blind roll sent to GM &lt;br/&gt;&lt;small&gt;(" + roll + ")&lt;/small&gt;."); sendChat(msg.who, "/gmroll " + roll + " from " + msg.who); } } }); on("chat:message", function(msg) { if(msg.type != "api") return; if(msg.content.contains("!rigroll ")) { var parts = msg.content.replace("!rigroll ", "").split(":"); var roll = parts[0]; var temp = roll.split("d"); var numdice = temp[0]; var faces = temp[1]; var modifier = parts[1]; var values = parts[2].split(","); 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;padding:0 4px 0 4px;margin:5px 0 5px 0"; var dicegroupingStyle = "display:inline"; var uisortableStyle = "cursor:move"; var rolledStyle = "cursor:move;font-weight:bold;color:black;font-size:1.4em"; var uidraggableStyle = "cursor:move"; var html = "&lt;div style=\"" + formulaStyle + "\"&gt; rolling " + numdice + "d" + faces + modifier + " &lt;/div&gt;"; html += "&lt;div style=\"" + clearStyle + "\"&gt;&lt;/div&gt;"; html += "&lt;div style=\"" + formulaStyle + ";" + formattedFormulaStyle + "\"&gt;"; html += " &lt;div style=\"" + dicegroupingStyle + ";" + uisortableStyle + "\" data-groupindex=\"0\"&gt;"; var total = 0; html += " ("; for(var i = 0; i &lt; numdice; i++) { var value = values[i]; var color="black"; if (value == "1") { color="#730505"; } else if (value == faces) { color="#247305"; } 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 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 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"; html += " &lt;div data-origindex=\"0\" style=\"" + dicerollStyle + "\" class=\"diceroll d" + faces + "\"&gt;"; html += " &lt;div style=\"" + diconStyle + "\"&gt;"; html += " &lt;div class=\"backing\"&gt;&lt;/div&gt;" html += " &lt;div style=\"" + didrollStyle + "\"&gt;" total += eval(value); if ((value=="1")||(value==faces)){ html+= "&lt;strong&gt;" } html += value; if ((value=="1")||(value==faces)){ html+= "&lt;/strong&gt;" } html += "&lt;/div&gt;"; html += " &lt;div style=\"" + backingStyle + "\"&gt;&lt;/div&gt;"; html += " &lt;/div&gt;"; html += " &lt;/div&gt;"; if(i == numdice - 1) html += ")"; else html += "+"; } html += " &lt;/div&gt;"; total = eval(total + modifier); html += modifier; html += "&lt;/div&gt;"; html += "&lt;div style=\"" + clearStyle + "\"&gt;&lt;/div&gt;&lt;strong&gt; = &lt;/strong&gt;&lt;div style=\"" + totalStyle + ";" + uidraggableStyle + "\"&gt;&lt;strong&gt;&lt;font size=\"6\"&gt; " + total + "&lt;/strong&gt; &lt;/div&gt;"; sendChat(msg.who, "/direct " + html); sendChat("Roll20", "/w gm " + roll + " was rigged to have values " + values.join() + "."); } });
1435106433
Aaron: When you tested the script out, did you actually get a result of an actual, normal inline roll output? Because when I replace the existing one with the version you posted, I get:
1435109049

Edited 1435109084
The modified version substitutes in the values of inline rolls, but still submits it to /gmroll, so "!blindroll [[1d20]]" will send "/gmroll 12" instead of "/gmroll $[[0]]", but "/gmroll 12" will still fail as you've seen. You'd have to change the "/gmroll" to "/w gm", although that will break the "!blindroll 1d20" use case. There is a HiddenRolls script which works on inline rolls (but not "/roll" commands) which you could use in conjunction with the (original or modified version of) Blind Roll to cover all your cases (e.g. "/roll 1d20" =&gt; "!blindroll 1d20", but "[[1d20]]" =&gt; "!hideall [[1d20]]", or "!hideall -v [[1d20]]" if you wanted everyone to know you're rolling 1d20).
1435112114
The Aaron
Forum Champion
API Scripter
The Aaron said: BTW, I didn't test this, but it's a pretty minor change (so far) and should work fine. It should function identically to the original, save that it will expand inline rolls before sending the dice expression. I just tested it and that is the case. If it needs to do more, of course, I can expand it. =D
1435113014
I missed that line. Anyway, the pic is the result of your edit, which Manveti seems to have explained, in that the script is parsing the inline roll, but only outputting it as small text, not the actual hoverable roll graphic. I checked out his Hidden Rolls script, and provided I can get everyone to change their macros to "!hideall [[1d20+x]]", everything would be fine. But if I could just use the BlindRoll script so they don't have to change anything, that would be ideal. The purpose of needing things inline is mostly for me to keep chat readable on my end.
1435113444
The Aaron
Forum Champion
API Scripter
So, their macros are: !blindroll 1d20+@{some|attribute} currently and you'd like them to become: !hideall [[1d20+@{some|attribute}]] or is there more too it than that?
1435113493
The Aaron
Forum Champion
API Scripter
Askren said: The purpose of needing things inline is mostly for me to keep chat readable on my end. AH. Now I see what you're getting at. You aren't looking to support inline rolls and nexted inline rolls, you're just looking to have the format of the result changed.
1435114107
The Aaron
Forum Champion
API Scripter
See if this works for you: Source: /******************************************************************************* * rollers.js - Provides specialized dice rolling alternatives. * * Dependencies: none ******************************************************************************* * * Commands for performing specialty dice rolling. * * !blindroll roll * Players may issue this command to have a roll of the dice generated in * secret to the GM only. This is useful when the player should not know * the result of the roll (e.g., a Stealth check). * * Example: * !blindroll 1d20+7 Stealth check * This example would be rolled as a GM roll so that the results are only * visible to the GM. * * !rigroll &lt;num dice&gt;d&lt;num sides&gt;:&lt;modifier&gt;:&lt;actual rolls (comma-separated)&gt; * Occasionally, a GM may want to exert control over fate and have the dice * fall a certain way (for cinematic reasons or to avoid a TPK). This command * allows a GM to roll "in the open" and still get the desired outcome. * This command cannot currently deal with complex roll types that are * available generally in Roll20. * Whenever this command is issued, the GM also receives a whisper informing * him of the rigged roll. This is favored over simply denying players the * ability to rig rolls because there may be times when the GM and a player * conspire together for story purposes and require a particular outcome. * * Examples: * !rigroll 1d20:+3:18 * !rigroll 5d4:+8:2,3,1,3,4 * The first example would produce a result of 21 (showing that an 18 was * rolled). The second example would also produce a result of 21 (showing * that a 2, 3, 1, 3, and 4 were rolled. * ******************************************************************************* * Copyright (C) 2014 Aaron Garrett (<a href="mailto:aaron.lee.garrett@gmail.com" rel="nofollow">aaron.lee.garrett@gmail.com</a>) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see &lt;<a href="http://www.gnu.org/licenses/" rel="nofollow">http://www.gnu.org/licenses/</a>&gt;. *******************************************************************************/ if(!('contains' in String.prototype)) { String.prototype.contains = function(str, startIndex) { return ''.indexOf.call(this, str, startIndex) !== -1; }; } var inspired = inspired || {}; on("chat:message", function(msg) { if(msg.type != "api") return; if(msg.content.contains("!blindroll ")) { var roll = msg.content.replace("!blindroll ", "").trim(); if(roll.length &gt; 0) { sendChat(msg.who, "Blind roll sent to GM &lt;br/&gt;&lt;small&gt;(" + roll + ")&lt;/small&gt;."); sendChat(msg.who, "/w gm [[" + roll + "]] from " + msg.who); } } }); on("chat:message", function(msg) { if(msg.type != "api") return; if(msg.content.contains("!rigroll ")) { var parts = msg.content.replace("!rigroll ", "").split(":"); var roll = parts[0]; var temp = roll.split("d"); var numdice = temp[0]; var faces = temp[1]; var modifier = parts[1]; var values = parts[2].split(","); 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;padding:0 4px 0 4px;margin:5px 0 5px 0"; var dicegroupingStyle = "display:inline"; var uisortableStyle = "cursor:move"; var rolledStyle = "cursor:move;font-weight:bold;color:black;font-size:1.4em"; var uidraggableStyle = "cursor:move"; var html = "&lt;div style=\"" + formulaStyle + "\"&gt; rolling " + numdice + "d" + faces + modifier + " &lt;/div&gt;"; html += "&lt;div style=\"" + clearStyle + "\"&gt;&lt;/div&gt;"; html += "&lt;div style=\"" + formulaStyle + ";" + formattedFormulaStyle + "\"&gt;"; html += " &lt;div style=\"" + dicegroupingStyle + ";" + uisortableStyle + "\" data-groupindex=\"0\"&gt;"; var total = 0; html += " ("; for(var i = 0; i &lt; numdice; i++) { var value = values[i]; var color="black"; if (value == "1") { color="#730505"; } else if (value == faces) { color="#247305"; } 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 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 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"; html += " &lt;div data-origindex=\"0\" style=\"" + dicerollStyle + "\" class=\"diceroll d" + faces + "\"&gt;"; html += " &lt;div style=\"" + diconStyle + "\"&gt;"; html += " &lt;div class=\"backing\"&gt;&lt;/div&gt;" html += " &lt;div style=\"" + didrollStyle + "\"&gt;" total += eval(value); if ((value=="1")||(value==faces)){ html+= "&lt;strong&gt;" } html += value; if ((value=="1")||(value==faces)){ html+= "&lt;/strong&gt;" } html += "&lt;/div&gt;"; html += " &lt;div style=\"" + backingStyle + "\"&gt;&lt;/div&gt;"; html += " &lt;/div&gt;"; html += " &lt;/div&gt;"; if(i == numdice - 1) html += ")"; else html += "+"; } html += " &lt;/div&gt;"; total = eval(total + modifier); html += modifier; html += "&lt;/div&gt;"; html += "&lt;div style=\"" + clearStyle + "\"&gt;&lt;/div&gt;&lt;strong&gt; = &lt;/strong&gt;&lt;div style=\"" + totalStyle + ";" + uidraggableStyle + "\"&gt;&lt;strong&gt;&lt;font size=\"6\"&gt; " + total + "&lt;/strong&gt; &lt;/div&gt;"; sendChat(msg.who, "/direct " + html); sendChat("Roll20", "/w gm " + roll + " was rigged to have values " + values.join() + "."); } });