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

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
Roll20 Production Team
API Scripter
What’s this for, the OGL?
The Aaron said: What’s this for, the OGL? Yes