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

nested rolls for a button / rolltemplate

I have the feeling the answer to this is "it can't be done", but I'll give it a shot anyway... In Traveller, damage from a weapon is given by a specified dice roll + the amount by which the "to hit" attempt succeeded.  For example, to shoot somebody with a weapon, i first need to roll 2d6 with various skill modifiers, and get a result of 8 or better.  The amount by which the roll succeeds is called the "effect", and this amount gets added to the weapon's base damage. I'm trying to handle the attack and damage rolls in one button on a character sheet. In other words, what I'd like to do looks something like this: <button type="roll" value="&{template: my-template} {{damage = [[3d6 + {{attack= [[2d6]]}} - 8]] }}">Fire Weapon</button> or this (I already know this syntax is wrong) <button type="roll" value="&{template:my-template} {{attack= [[2d6]]}} {{damage= [[3d6 + &{attack} - 8]]}}">Fire Weapon</button> My roll  template would then first check {{attack}} to see if it exceeded 8, and if it did, the {{damage}} would be displayed.  (As long as I have both a valid attack and damage result, I know I can handle that part!) The question is... is there a syntax to allow me to nest the two rolls in the button definition? Or is there a way I that I'm missing can do math on the two separate results later in the roll template?
1546742023
GiGs
Pro
Sheet Author
API Scripter
There's no practical way to do this with a rolltemplate. Rolltemplates and basic dice macros alike cant use the outcome of one roll to affect another roll. For certain simple situations, you can fake it with a rolltemplate. But you essentially need to manually build a nested table of effects (a matrix) with one row for every possible roll at the attack, and a column for every roll on the damage dice. It gets very complicated (with a 2d6 roll followed by a 3d6 roll, you could have ~200 cells, and I'm sure damage can go higher than 3d6).  The only way to do it is with an API script, which as a Pro user you can use. But if you are planning to make this sheet for general users, they won't be able to use that script.
That's what I figured.  (The damage rolls can definitely get higher than 3d6, btw, so the table/matrix is impractical.)  As a workaround for now, I'm using a series of {{#rollTotal() attack <number>}} checks to display the "added damage" that the roller would have to manually add to the basic damage roll.  It'll do for now.