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

Mod Help - Get the full roll result of a roll to redisplay in another sendChat

I am working on a D5e gunslinger mod that can calculate misfires.  I want to roll  d20 + wisdom mod + pb and evaluate the  d20  and determine if it fails against a misfire number and if it is a critical hit [1d20cs20],then display the result total and formula [[1d20 + wis mod + pb]] of rolls in another sendChat with updated description. I am using the D5e roll20 character sheet. What I am trying to figure out is the current script isn't displaying the critical success (the green or red highlight) without being calculated inline after it has been rolled. Here is what I have so far, I can get the roll result or the critical success, but not both to display in chat.              let r1 = '1d20cs>20' ;             let misfire = 2 ;             sendChat ( msg .who, "&{template:atk} {{mod=" + mod + "}} {{rname=" + rnamet + "}} {{rnamec=" + rnamec + "}} {{r1=[[" + r1 + "]]}} {{" + rolltype + "=1}} {{r2=[[" + r2 + "]]}}     {{range=" + range + "}} {{desc=" + desc + "}}  ammo=" + ammot + "{{charname=" + charname + "}}" , function ( ops ){                 var rollresult1 = ops [ 0 ] . content .inlinerolls [ 0 ] ;                 var rollresult2 = ops [ 0 ] . content .inlinerolls [ 1 ] ;                 if ( rollresult <= misfire ) { if ( atk1d20 <= misfire ) { desc += 'Attack1: "' + atk1total + ' !!!MISFIRED!!! \n ' ;}}                 sendChat ( msg .who, "&{template:atk} {{mod=" + "1" + "}} {{rname=" + rnamet + "}} {{rnamec=" + rnamec + "}} {{r1=[[" + rollresult1 + wismod + pb + "]]}} {{" + rolltype + "=1}} {{r2=[[" + rollresult2 + "]]}}     {{range=" + range + "}} {{desc=" + desc + "}}  ammo=" + ammot + "{{charname=" + charname + "}}" ) ;             } ) ;
1677858698

Edited 1677858930
timmaugh
Pro
API Scripter
If you plug in libInline to your project, you can have it render the roll tip and formatting for you. In your sendChat callback, you could send your inline rolls through libInline to get back the parsed information you need, then use the getRollTip() function in place of this: [[" + rollresult2 + "]] I'm not sure where you define your r2, nor atk1d20, nor the rollresult  that is in the if() check against the misfire, and I'm not sure you need the roll template sent through the callback... not if you're only interested in the rolls. So, in that case, I'll have to change a couple of things to give you an example, but you could simplify things and employ libInline something like (air-coded...): let r2 = `1d20cs>20`,     r1 = `${r2}+${wismod}+${pb}`; let misfire = 2; sendChat('', `[[${r1}]] [[${r2}]]`, function (ops) {     let parsedInline = libInline.getRollData(ops[0]);     if (parsedInline[0].getDice('all')[0] <= misfire) {         desc += `Attack1: !!!MISFIRED!!!\n`;     } else if (parsedInline[0].getDice('crit').length > 0) {         desc += `Attack1: !!!CRITICAL!!!\n***TOTAL DMG: ${parsedInline[0].getValue() + parsedInline[1].getValue()}***`;     }     sendChat(msg.who, `&{template:atk} {{mod=1}} {{rname=${rnamet}}} {{rnamec=${rnamec}}} {{r1=${parsedInline[0].getRollTip()}}} {{${rolltype}=1}} {{r2=${parsedInline[1].getRollTip()}}} {{range=${range}}} {{desc=${desc}}} ammo=${ammot} {{charname=${charname}}}`); }); I made assumptions about things... like that the wisdom mod and pb should only be added once if you critical... and that your misfire check should come from the d20 involved in the first roll -- not from the combined result of the roll counting the wisdom mod and pb. The point is you can see how I am able to retrieve information from the roll returned from the callback by using libInline. BTW, I haven't output to the atk template much (not a 5E player), so if using the rolltip like this doesn't work, let me know and I can look for the proper syntax to make it happen. EDIT: Also, you could put a fail threshold in your roll equation, then extract the "fail" dice the same way I later extract the "crit" dice. Just a preference thing, but that way you wouldn't have to check against your misfire threshold, and your "critical failure" formatting for the final display to the chat output would have the red for a failure. That would look like: let misfire = 2; let r2 = `1d20cs>20cf<${misfire}`,     r1 = `${r2}+${wismod}+${pb}`;