I wrote a very simple script to print the total of inline rolls made with a + in front of them. (Feel free to berate my coding habbits.) If you want to have unique inline rolls, and total them, you simply write it like this. +[[roll]] Any roll in the chat block you don't want to total just place them inline as normal. [[roll]]. Input: I've added these two numbers +[[20]] +[[100]] but not this number [[5]]. Output: I've added these two numbers +20 +100 but not this number 5. Total: 120 rolladdition = 0;
on("chat:message", function(msg) {
if(msg.type === "general" && msg.inlinerolls && msg.who !== 'Total'){
var rolls = -1 + msg.inlinerolls.length;
if(msg.content.indexOf('$[[0]]') !== -1) {
rolladdition = 0;
}
var arrayMatch = msg.content.match(/\+\$\[\[\d+\]\]/g);
if(arrayMatch){
for (var i=0; i < arrayMatch.length; i++){
rolladdition += Number(msg.inlinerolls[arrayMatch[i].match(/\d+/)[0]].results.total);
}
}
if(rolladdition > 0 && msg.content.indexOf('$[['+rolls+']]') !== -1){
sendChat('Total','[['+rolladdition+']]');
rolladdition = 0;
}
}});