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 .
×
Create a free account

[Script] Secret Die Roller

1484341728

Edited 1484344136
Hi,    In order to prevent meta gaming in my games I have made a secret die roller, with a handy reveal button. The players can make secret die rolls and the result is sent to the GM. A reveal button is created in the chat window which displays the results to everyone else. If the gm doesn't trust the players the reveal button can be hidden. I think this has been done before, but it was a while ago before it was possible to put buttons in the chat window. To use any player can type !SDR /roll 1d20+3 stealth roll /*SECRET DIE ROLLER WITH REVEAL BUTTON WRITTEN BY JACK TAYLOR JAN 2017 FOR THE ROLL20 GAME ENGINE THIS SCRIPT IS DESIGNED TO PREVENT META GAMING THE PLAYERS AND GM CAN MAKE SECRET DICE ROLLS WITH ONLY THE RESULT BEING SHOWN TO THE GM A REVEAL BUTTON IS ADDED TO THE CHAT WINDOW SO THAT THE RESULT OF THE DIE ROLL CAN BE DISPLAYED IN THE CHAT WINDOW TO USE TYPE SET TRUST TO FALSE TO REMOVE THE REVEAL BUTTON FROM THE PLAYERS CHAT WINDOW !SDR <roll 20 roll equation> example !SDR /roll 1d20+6 Stealth roll */ // var TRUST=true; function SecretDieRoll(Player,dr) { sendChat(Player,"secret roll "+dr) sendChat("SDR SCRIPT", dr, function(ops) { // ops will be an ARRAY of command results. if(ops[0].type=='rollresult') { var rollresult = ops[0].content; var rollobject = JSON.parse(rollresult); sendChat("DM","/w gm " + rollobject.total); r = ""; if(!TRUST){r = "/w gm ";} //replace any brackets with curly braces in players name np = Player.replace("(","{").replace(")","}"); sendChat("DM",r + "[Reveal Result](!REVEAL "+ np +" rolled " + rollobject.total+")"); }else { sendChat("DM","ROLL ERROR NONSENSE"); } }); } function RevealSecretDieRoll(text) { sendChat("SECRET REVEALED",text); } on("chat:message", function(msg) { try { if(msg.type == "api") { var S = ""; if( msg.content.indexOf("!SDR ") != -1) { S = msg.content.replace("!SDR ", ""); SecretDieRoll(msg.who,S); } if( msg.content.indexOf("!REVEAL ") != -1) { S = msg.content.replace("!REVEAL ", ""); RevealSecretDieRoll(S); } } } catch(err) { sendChat("SECRET DIE ROLL SCRIPT EXCEPTION",err.message); } });
Fixed bug - you can't have brackets in the players name