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

Roll template : 2 questions for more complex calculation

Hi all, I am trying to update a sheet that isn't fitting completly the requirement to run a specific game. And i must say that i am not used to HTML and javascript. May be i am missing some basic knowledge that make those issues trivials. I am actually a bit stucked and running out of patient / understanding. If someone could help, i will be glad. Below the 2 points that i am trying to achieves to a roll template: - the game rule is : when a player make a critical roll then the involved skill level is added to a margin calculated from the result of the roll (ex: roll is 13 then margin will be 3, if roll was a crit then skill level is added (skill level isn't directly involved in the roll), let say 10 in skill, making final margin to 13)      => here i have difficulties to simply make the sum and display (margin is retrieved from "rollBetween"). skill level could be passed as roll parameter but i would like to avoid that and it lead to second question. - to avoid code repetition and simply modifications i am trying to retrieve some form atttributs in the roll template. let say skills have a level and a score (skill level plus modificator like strength bonus or other bonus). this one is used for the roll. both attributs are following the naming rule attr_strengthX or attr_strengthY.      => i just want to pass "strength" to the roll and retrive all linked attributs.
1566124660
Finderski
Pro
Sheet Author
Compendium Curator
Not sure I fully follow what you're trying to accomplish, but...it sounds like you want the Roll Template to actually calculate stuff and they can't.  They can evaluate things and display information based on that evaluation, but they can't do any math. You could alter the display based on information received, but you'd need to pass all the information in first. So, you could  pass in a a roll that already includes the skill level in the calculation, but it sounds like even that is calculated based on a variable in the die roll (for example roll 13 if Crit then 3 + skill level). To accomplish that with a roll template is going to require A LOT of information to be passed to the roll template via the roll AND a bunch of code in the template to handle all the different scenarios...and I still don't think it would work quite right. The only way I see to accomplish something like this would be via the API... That all assumes I understood the issue correctly.
Thanks Finderski for your answer. I will try to wrap the roll with JS to be able to send all necessary value at the roll call (specifically skill level + skill score). will see
1566412895
GiGs
Pro
Sheet Author
API Scripter
If you describe exactly how an example roll works, and name all attributes on the sheet that are involved in that roll, and say what they do in the roll, we might be able to give more concrete help.
1566507244

Edited 1566507953
ok  How the roll are working in this game exactly : 1- select a difficulty modifier on the roll (0, +-3, +-5 and so on) 2- add this modifier to skill score. skill score is the sum of skill level plus attribut modifier (like strength bonus). the final result give you the treshold for success. 3- roll a 1d20.    a- if result is stickly above treshold, it is a failure (having 20 is a critical failure. this part is easy, i won't go further)     b- if result is under the treshold, it is a success. margin will be calculated on the resulting roll (higher better. ex: roll give 13 and treshold is 15 (7 of skill level), it is a success. if roll give 2, it is too a success but with less margin)     b- if result is equal to the treshold this is a critical success. skill level is added to the result of the dice (so result is treshold + skill level. for treshold above 20, 20 is consider a critical success in this case. no critical failure possible). same, margin will be calculated on the resulting total score (on above example, critical success is with a roll of 15 and margin is calculated with 15+7 = 22) 4- margin is determined by a sheet, not fully logical. example: if total score if between 12 and 14, margin is equal to bonus of +5. so idealy, i would have to make some calculation in rolltemplate (value modification before roll, after roll done and then calculate margin). But it seems here that I would have to modify skill score on the sheet with the difficulty modifier (or to have another attribut by skill, maybe hidden). difficulty modifier to be set independently of the roll. add another attribut for critical success equal to treshold + skill level (maybe hidden too). both to be passed as parameter to the roll template. for critical success i must set, somehow, a roll with only one result (treshold + skill level). and margin would be calculated with rollbetween.  no wrapping possible (no real JS) and anyway sheet worker can't call roll (or i didn't found.
1566521045

Edited 1566521121
GiGs
Pro
Sheet Author
API Scripter
I'm not 100% clear on the roll, but it does look like you'll be able to handle it through a roll template, specifically using the logic functions described here . You'd have a button with the value something like  value="&{template:mysystem} {{roll=1d20}} {{score=[[@{skill} + @{attribute} + ?{modifier|0}]] }}" You'd probably want other stuff in the rolltemplate like character name, skill name, and so on, but the above is the bare minimum needed. Then in your roll template, you can use the logic functions to compare score to roll, and have the margin calculated by including the table in the template. <rolltemplate class="sheet-rolltemplate-mysystem"> <div class="sheet-template-container"> {{#rollTotal() roll 20}} text here for a fumble {{/rollTotal() roll 20}} {{#^rollTotal() roll 20}} <!-- handle what happens when its not a fumble --> {{#rollGreater() roll score}} text here for a failure {{/rollGreater() roll score}} {{#rollTotal() roll score}} text here for a critical {{/rollTotal() roll score}} {{#rollLess() roll score}} <!-- here you put what happens on a success --> {{#rollBetween() 12 14}} what happens when roll is a success, and between 12 and 14. {{/rollBetween() 12 14}} {{/rollLess() roll score}} {{/^rollTotal() roll 20}} </div> </rolltemplate> The tricky part though is you cannot perform calculations within a rolltemplate, you can only add text, and format it with css.  So if you need to perform any calculations, you'd need to pre-calculate them ibn the dice macro. for instance, say you do damage +5 on a success of 12-14, you'd need to create that result in the initial roll value, and give it a  name like: value="&{template:mysystem} {{roll=1d20}} {{score=[[@{skill} + @{attribute} + ?{modifier|0}]] }} {{damage1214=[[1d6+5]] }}" and then call it in the relevant part of the rolltemplate, like so {{#rollBetween() 12 14}}         damage: {{damage1214}} {{/rollBetween() 12 14}} Creating rolltemplates can get pretty laborious, but with imagination can cover pretty complex situations. But there are still things they cannot do. I cant tell from your description if this is one of those.