Thanks a lot, I have heavily borrowed from your original script and came up with something that actually works (considering that it's the first time that I program using javascript, it's something of a miracle). It's probably not robust, but I think that the basis are there. Testers are welcome, all suggestions are appreciated. Usage is: !brr (Target|*) [Skill [Bonus]] You can specify a target or you can put * so that it is sent to all the players (It's in a /em because I did not find another option that worked, suggestions are welcome). So, simplest form is: !brr Vecna to ask for a simple roll from Vecna !brr Vecna Stealth to let him know that it's a stealth check !brr Vecna Stealth 6 to let him know that it's going to be made with a +6 bonus For me, the intent is for it to be called from a macro (and more precisely a token action), with the skill and value computed by the macro from a character sheet. // Github: BlindRoll.js
// By: Philippe K., Great Old One
// Contact: <a href="https://app.roll20.net/users/321064" rel="nofollow">https://app.roll20.net/users/321064</a>
var BlindRoll = BlindRoll || (function() {
'use strict';
var version = '0.0.1',
lastUpdate = 150995981,
roller,
rollN = 0,
skill = "",
bonus = 0,
checkInstall = function() {
log('-=> BlindRoll v'+version+' <=- ['+(new Date(lastUpdate*1000))+']');
},
handleInput = function(msg_orig) {
var msg = _.clone(msg_orig);
if (msg.type !== "api") {
return;
}
// brr - Blind Roll Request, sent by the GM, Format is !brr (Target|*) [Skill [Bonus]]
if(msg.content.indexOf("!brr ") !== -1) {
var params = msg.content.replace("!brr ", "").split(" ",3)
roller = params[0];
rollN = Date.now();
var chatCommand = (roller == '*' ? "/em" : "/w "+roller);
switch(params.length) {
case 3:
skill = params[1];
bonus = params[2];
sendChat("GM", chatCommand+" [Blind "+skill+" Roll - Modifier "+(bonus <0 ? '' : '+')+bonus+" ](!bra "+rollN+") ", null, {noarchive:true} );
break;
case 2:
skill = params[1];
bonus = 0;
sendChat("GM", chatCommand+" [Blind "+skill+" Roll](!bra "+rollN+") ", null, {noarchive:true} );
break;
default:
skill = "";
bonus = 0;
sendChat("GM", chatCommand+" [Blind Roll](!bra "+rollN+") ", null, {noarchive:true} );
}
}
// bra - Blind Roll Answer, send back by the button in the chat of the target
if(msg.content.indexOf("!bra ") !== -1) {
if (rollN == 0 || msg.content.replace("!bra ", "") != rollN) {
sendChat("GM", "/w "+(roller == '*' ? msg.who : roller)+" Only one roll, please...");
} else {
sendChat("GM", "/w "+(roller == '*' ? msg.who : roller)+" Thanks for the "+(skill == '' ? '' : skill+' ')+"roll!");
sendChat((roller == '*' ? msg.who : roller), "/w GM Blind "+(skill == '' ? '' : skill+' ')+"Roll [[d20"+(bonus < 0 ? bonus : '')+(bonus > 0 ? '+'+bonus : '')+"]]");
rollN = 0;
}
}
},
registerEventHandlers = function() {
on('chat:message', handleInput);
};
return {
CheckInstall: checkInstall,
RegisterEventHandlers: registerEventHandlers
};
}());
on('ready',function() {
'use strict';
BlindRoll.CheckInstall();
BlindRoll.RegisterEventHandlers();
});