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

Auto-calculated value and variable dice number in roll template

1426886206
Kevin the Barbarian
Pro
Sheet Author
API Scripter
I need to show a variable number of dice rolled - both the result and how many were rolled. As you can see in the character sheet excerpt, players will click the button called rollTalent1Check. attr_talent_1_val should be the brains attribute + 3. Assume a brains score of 2 for this example. The player should see that the die rolled is 5d6. It's being displayed as 2+3d6 and the check itself is the number 2 plus 3d6. I'm guessing that @{brains+3} is being interpolated as text instead of an integer. What am I doing wrong? The character sheet: <div class="sheet-col"><input type="number" name="attr_talent_1_val" value="@{brains+3}" disabled="true"><button type='roll' value='&{template:buster} {{name=@{talent_1}}} {{die=@{talent_1_val}}} {{check=[[@{talent_1_val}d6]]}}' name='rollTalent1Check' /></div> The roll template excerpt: <div class="sheet-rolltemplate-content"> <h3>{{name}} Check</h3> <span class="sheet-rolltemplate-die">{{die}}d6</span> <span class="sheet-rolltemplate-result">{{check}}</span> </div>
1426886441
Kryx
Pro
Sheet Author
API Scripter
It needs to be value="@{brains}+3" I believe.
1426886603
Kevin the Barbarian
Pro
Sheet Author
API Scripter
That still shows "3+3d6" and the actual check is 3+(1+4+3).
1426886991
Diana P
Pro
Sheet Author
Try value="(@{brains}+3)" Otherwise you get a direct substitution to @{brains} +3d6 instead of (@{brains}+3)d6. Though you might need {@{brains}+3} instead; I tend to forget when you need to use the () vs {} so I try both. :)
1426887537
Kevin the Barbarian
Pro
Sheet Author
API Scripter
Diana, your first example, with the parens around the whole expression, fixes the check. The die display of how many dice used just looks like: "(3+3)d6". Trying with the brackets around the entire thing just seems to break it even more!
1426888006
Diana P
Pro
Sheet Author
If the {} breaks it more, definitely don't use it! :D If you want the display to read the result, not spell out the math, then just enclose it in [[ ]] as well in your roll: {{die=[[@{talent_1_val}]] }} Poor computer doesn't know to actually add it up otherwise.
1426888402
Kevin the Barbarian
Pro
Sheet Author
API Scripter
Thanks, *that* is what I was looking for. I've tried so many variations on the syntax that I wasn't quite sure what to do. I know I've already tried using [[]] but I might have put it around the wrong thing or something like that. This should do it!
1426888703
Diana P
Pro
Sheet Author
Good. Glad it's working now. It can be difficult to figure out whats wrong sometime when you've stared at the same piece of code for far too long. Brain fatigue, I guess.