Roll20 experienced a Security Breach. And Fanburst is shutting down. Please click to read.
Advertisement Create a free account

Scriptmancer Wanted! Trying to make this work for players as well as NPCs instead of just NPC

As Title states looking for some help making this auto roll for players via spellcard like this does via an npc action, is that possible? on('chat:message', function(msg) { // ROLL LISTENER if(msg.playerid.toLowerCase() != "api" && msg.rolltemplate) { if (msg.rolltemplate === "npcaction"){ let desc = ((msg.content.split("{{description=")[1]||'').split("}}")[0]||''); if (desc.match(/\(\d+(d)\d+.*\)/g)) { let output =[]; let roll = desc.match(/\(\d+(d)\d+.*\)/g); let type = desc.match(/\)\s\w+/g); for (let n = 0; n < roll.length; n++) { output[n] = {die: roll[n].replace(/\(/g, "[[").replace(/\)/g, "]]"), type: type[n].replace(") ", "")}; } for (let x of output) { sendChat(msg.who, "/w gm &{template:npcdmg} {{damage=1}} {{dmg1=" + x.die + "}} {{dmg1flag=1}} {{dmg1type=" + x.type + "}}"); } } } } }); on('chat:message', function(msg) { // ROLL LISTENER if(msg.playerid.toLowerCase() != "api" && msg.rolltemplate) { if (msg.rolltemplate === "spell"){ let desc = ((msg.content.split("{{description=")[1]||'').split("}}")[0]||''); if (desc.match(/\(\d+(d)\d+.*\)/g)) { let output =[]; let roll = desc.match(/\(\d+(d)\d+.*\)/g); let type = desc.match(/\)\s\w+/g); for (let n = 0; n < roll.length; n++) { output[n] = {die: roll[n].replace(/\(/g, "[[").replace(/\)/g, "]]"), type: type[n].replace(") ", "")}; } for (let x of output) { sendChat(msg.who, "&{template:npcdmg} {{damage=1}} {{dmg1=" + x.die + "}} {{dmg1flag=1}} {{dmg1type=" + x.type + "}}"); } } } } });
1549814066
The Aaron
Forum Champion
API Scripter
What’s this for, the OGL?
The Aaron said: What’s this for, the OGL? Yes