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

Accessing Results of Template Roll

1599583598
Nick O.
Forum Champion
I'd like to execute a specific sequence of commands if one of my players rolls a nat 1 or nat 20. I've got it figured out for straight rolls (i.e., they type in /r 1d20 ) but I can't figure out how to check the results of a roll when they click on an attack or save via the link from the 5e OGL character sheet. Any help is most appreciated :)
1599584216
The Aaron
Roll20 Production Team
API Scripter
This will be a 2-step process.  First you have to parse the content field of the message to find the roll index, it will look like $[[0]] or similar. Second, you have to find the roll in the inlinerolls field of the message and get the roll.   After that, you can do your logic on the value and perform output.  Here's what the structure looks like (for a Lich's Melf's Acid Arrow (cuz that was handy...) ): { "content": " {{attack=1}} {{damage=1}} {{dmg1flag=1}} {{name=Lich}} {{rname=[Melf's Acid Arrow](~-MClN7CxELQc-W2E_Yf8|repeating_npcaction_-MClN7NOh9l-snJSxKxl_npc_dmg)}} {{rnamec=[Melf's Acid Arrow](~-MClN7CxELQc-W2E_Yf8|repeating_npcaction_-MClN7NOh9l-snJSxKxl_npc_crit)}} {{type=[^{attack-u}](~-MClN7CxELQc-W2E_Yf8|repeating_npcaction_-MClN7NOh9l-snJSxKxl_npc_dmg)}} {{typec=[^{attack-u}](~-MClN7CxELQc-W2E_Yf8|repeating_npcaction_-MClN7NOh9l-snJSxKxl_npc_crit)}} {{r1=$[[0]]}} {{always=1}} {{r2=$[[1]]}} charname=Lich", "inlinerolls": [ { "expression": "1d20+(12+0)", "results": { "resultType": "sum", "rolls": [ { "dice": 1, "results": [ { "v": 5 } ], "sides": 20, "type": "R" }, { "expr": "+(12+0)", "type": "M" } ], "total": 17, "type": "V" }, "rollid": "-MGic_vUv0Ne515qRJTP", "signature": "03eb1ac04d061e7850cb996948e399fcf7a3d45e765d1d5ac36cd9d3855015d760af3f3e3068c2427274078fb4f16668ca4b334128568e228270f51c5fe85ba0" }, { "expression": "1d20+(12+0)", "results": { "resultType": "sum", "rolls": [ { "dice": 1, "results": [ { "v": 1 } ], "sides": 20, "type": "R" }, { "expr": "+(12+0)", "type": "M" } ], "total": 13, "type": "V" }, "rollid": "-MGic_vUv0Ne515qRJTQ", "signature": "5b31c9e678f5ba38b7a557fa45945e0f58f4def3ca1aa69afc7ffaa1aa5dd94eca2d75472783cf35d308f39a8d0c411977883a62e614c420641659ae49f9296f" } ], "playerid": "-MA-6LlhK58UhtPa2ib7", "rolltemplate": "npcatk", "type": "general", "who": "The Aaron (GM)" } You can see r1 and r2 are the two rolls for the attack.  r1 has index 0 and r2 has index 1, looking at the inline rolls, you can find the v: 5 for the first roll and the v: 1 for the second roll.
1599584916
Nick O.
Forum Champion
Aaron, you are brilliant! Thank you so much!
1599585079
The Aaron
Roll20 Production Team
API Scripter
No problem! =D