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

[Question] Auto-calculate number of successes in rolltemplate

1483903751
Loki
Sheet Author
Hi! I'm currently working on my first character sheet project here and trying to figure out how rolltemplates work. I'm creating a character sheet for a system where it matters how much a character did fail or not fail when he rolls the dice. Every 3 points the character exceeds or fails to reach to the given difficulty he becomes on step degree better or worse. Obviously the formula is simple: floor(({{difficulty}}-{{skill}})/3). But since rolltemplates seem to be pure HTML I don't see a way to calculate this. Is there any way I can output the calculated degree of success in a rolltemplate? Greetings, Loki
1483967546
Natha
KS Backer
Sheet Author
API Scripter
If you do the math inside the roll macro (the "value" of the roll button) and name it, you can use it in the template (for display or eventually basic tests with the  template helper functions ). For example, you could use "myvalue" in the template to show and/or test: <button type="roll" name="MYROLL" value="&{template:mytemplate} {{myroll=[[1d20+@{skill}]]}} {{myvalue=[[floor((@{difficulty}-@{skill})/3)]]}}  " >Roll !</button>
1483978987

Edited 1483979028
Loki
Sheet Author
Natha said: If you do the math inside the roll macro (the "value" of the roll button) and name it, you can use it in the template (for display or eventually basic tests with the  template helper functions ). For example, you could use "myvalue" in the template to show and/or test: <button type="roll" name="MYROLL" value="&{template:mytemplate} {{myroll=[[1d20+@{skill}]]}} {{myvalue=[[floor((@{difficulty}-@{skill})/3)]]}}  " >Roll !</button> Hi Natha and thanks for replying! I didn't test your solution, but I'm under the impression, that I may have expressed my problem a little bit unclear. What your solution does is to calculate "myvalue" from "difficulty" and "skill". So far so good. But what I want is that the roll template takes the result of the roll and then calculate something based on the result. I guess the call of the roll template is not able to access the roll result of that given template (because it rolls the dice afterwards). Or is something like this possible? <button type="roll" name="MYROLL" value="&{template:mytemplate} {{ myroll =[[1d20+@{skill}]]}} {{myvalue=[[floor((@{difficulty}-@{ myroll })/3)]]}}  " >Roll !</button> Greetings, Loki
1483993660

Edited 1483993691
Natha
KS Backer
Sheet Author
API Scripter
Unfortunately, no, you can't use the result of a single roll in 2 different computations ... at least not without the API. And it can be frustrating ;)
1484064493
Loki
Sheet Author
Ok and inside the rolltemplate itself (the html definition) I can generally not compute the roll result "freestyle" (that means outside of the few given functions like check for crit, etc.), right? Would be a pity.
1484072280

Edited 1484122411
Natha
KS Backer
Sheet Author
API Scripter
Except for helper functions (which are basically "if superior/inferior/equal/critical/fumble"), no computation at all is possible.
1484120567
Loki
Sheet Author
Alright, thanks!