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

Custom Roll Parsing (maybe?) - Advice required

1726392338
Steve
Pro
Sheet Author
I'd like some guidance on how to do more advanced dice rolling. I've got plenty of simple dice-roll's on my sheet, using attributes and queries and select queries. But now that I'm getting into this systems' spells means rolling dice, then the values on those dice are used for the next set of rolls in sequence. ie: "Roll 2d4 for a number of targets. For each target, roll 2d10  - success is @{finalmagicalattack} - ?{targets magical defence}." Do I need to use custom roll parsing for this? Is there a different method I should be considering? I started to ask this question yesterday, then found the posts on custom roll parsing - I've given it a go myself, but so far I'm not having much luck. Here's what I've produced (that does not work): <button type="action" name="act_rolltransfix" class="roll twod10">Roll Transfix</button> on('clicked:rolltransfix', function() {     startRoll(`&{template:default} {{name=Magical Attack Roll}}      {{targets=[[2d4]]}}`, (results) => {         let targetCount = results.results.targets.result;         // Loop over number of targets and roll 2d10 for each         let rolls = {};         for (let i = 1; i <= targetCount; i++) {             let finalAttack = `@{finalmagicalattack}`;             let targetDefense = `?{Target ${i} Magical Defence|0}`;             let comparison = finalAttack - targetDefense;             rolls[`target${i}`] = `[[2d10]] vs ${comparison}`;         }         finishRoll(results.rollId, rolls);     }); });
1726408991

Edited 1726409272
GiGs
Pro
Sheet Author
API Scripter
It looks like you are&nbsp; mixing up syntaxes a bit. This part (syntax corrected) ?{Target ${i} Magical Defence|0} needs to be part of the original roll string `&amp;{template:default} {{name=Magical Attack Roll}}&nbsp;{{targets=[[2d4]]}}` Which is difficult to do when you don't know the number of attacks ahead of time. Roll20 is not an automation engine. The way I'd do this is to make a single macro for the attack + 2d10 damage, then separately while talking to the DM, roll 2d4, then click the button for the attack that many times (declaring who you're attacking with each). That mirrors how its likely to work at the game table, too, and has the advantage that you don't need to use CRP which is cumbersome to implement for single actions. If you need to explore the sheet design side of things (and custom roll parsing), check out my site: <a href="https://cybersphere.me/roll20/" rel="nofollow">https://cybersphere.me/roll20/</a> Scroll down specifically for the CRP section and examples.
1726802319
Steve
Pro
Sheet Author
Yeah, okay. Getting a bit too ambitious then. I'll separate it into two dice roll buttons.