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

Math in roll templates?

Greetings! Just a quick question, is it possible to use simple math in roll templates? I'm trying to figure out the syntax (if even possible).  {{#rollTotal() throw 2}} <tr><td><span>Outcome: </span>(10% HP Loss)<br> <br><span>HP Loss: </span> {{round((@{HP_temp_loss}) / 10)}}</td></tr> {{/rollTotal() throw 2}} I copied my version. In this case the roll template gives the correct text if the 2d6 throws a '2' but I'm not sure on the 2nd part where I try to apply math to a variable since this math changes depending on the outcome of the 2d6. 
1472153719

Edited 1472154056
David
Sheet Author
No. As far as I am aware you have to do it outside. &{template:skillRoll} {{name=@{Name}}} {{skillvalue=@{artScore}}} {{fumble=[[ceil(95+(@{artScore}+?{Mods|0})/20))]]}} {{crit=[[ceil((@{artScore}+?{Mods|0})/20)+1]]}} {{special=[[ceil((@{artScore}+?{Mods|0})/5)+1]]}}
While you can't do math in the roll template per se , you can instead do it in inline rolls that you set for your variables. So, instead of this ... {{#rollTotal() throw 2}} <tr><td><span>Outcome: </span>(10% HP Loss)<br> <br><span>HP Loss: </span> {{round((@{HP_temp_loss}) / 10)}}</td></tr> {{/rollTotal() throw 2}} ... You could have this: ... {{#rollTotal() throw 2}} <tr><td><span>Outcome: </span>(10% HP Loss)<br> <br><span>HP Loss: </span> {{roundHP}}</td></tr> {{/rollTotal() throw 2}} ... and the call for said template would look something like: &{template:template_name}{{throw=[[2d6]]}}{{roundHP=[[round(@{HP_temp_loss}/10)]]}}
Thanks. I completely forgot about doing it outside the template. Though I do see it right that I have to attach the call to every button that I'm using for the throw, right? As that would mean adding 2d6, meaning 11 in my specific case, different cases of variables to every instance of that button instead of having it all in one place. 
1472157302

Edited 1472157368
Corin S.
Sheet Author
Depends on what you need to do for each case. Not knowing the particular rules, I can't really help, but, being a math guy, I know that there are many cases where you can use tricks to cut back on a bit of typing, or at the very least ease the computations necessary. If you are able to give or link to a description of the rules involved, I might be able to help.