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

Queries in Roll Templates?

1588926532

Edited 1588926558
Som context: I'm slowly writing a Traveller: The New Era sheet, based on the Twillight:2000 sheet. Both games use the GDW house system of the 1990s where skill checks are made against an "asset" made up of an "attribute" value and a "skill" value. Rolling under the asset on a d20 is a success. The asset is adjusted by difficulty, an Easy check is x4, Average x2, Difficult x1, Formidable x1/2 and Impossible x1/4. A roll of 10 less than the required number is an "outstandig success", a roll of 10 more than the required number is a "catastrophic failure". A 1 is always a sucess and a 20 is always a failure. In the Twilight:2000 sheet there is a skill-roll template and there are roll-buttons that handle this. However the difficulty query is done in the roll-button, and while I'm new to programming it seems counterintuitive to repeat all this code for each button, instead of putting it in the roll-template. Is it possible? This is the current roll-template, unchanged from the TW:2000 sheet: <rolltemplate class="sheet-rolltemplate-skillRoll"> <!-- Skill roll --> <table class="skillRoll" style="width: 100%; border 1px black"> <!--<tr><th>{{name}}</th></tr>--> <tr><th colspan="2">{{name}}</th></tr> <tr><th colspan="2">Skill Roll</th></tr> <tr><th colspan="2">{{skillname}}</th></tr> <!--<tr><td>os</td><td>{{os}}</td></td> <tr><td>CF</td><td>{{cf}}</td></td>--> <tr> <tr> <td class="template_label"><b>Skill:</b> </td> <td class="sheet-rolltemplate-skillRoll-template_value"> {{skillvalue}} ({{success}})</td> </tr> </tr> <tr> <td class="template_label"><b>Rolled:</b></td> <td class="sheet-rolltemplate-skillRoll-template_value"> {{roll}}</td> </tr> <tr> <td class="template_label"><b>Result:</b></td> <!-- Check for outstanding success --> {{#^rollGreater() roll os}} {{#rollTotal() roll 20}} <td class="sheet-rolltemplate-skillRoll-template_value">Failure</td> {{/rollTotal() roll 20}} {{#^rollTotal() roll 20}} <td class="sheet-rolltemplate-skillRoll-template_value">Outstanding Success</td> {{/^rollTotal() roll 20}} {{/^rollGreater() roll os}} {{#rollGreater() roll os}} {{#rollLess() roll cf}} {{#rollGreater() roll success}} <!-- Failure --> {{#rollTotal() roll 1}} <td class="sheet-rolltemplate-skillRoll-template_value">Success</td> {{/rollTotal() roll 1}} {{#^rollTotal() roll 1}} <td class="sheet-rolltemplate-skillRoll-template_value">Failure</td> {{/^rollTotal() roll 1}} {{/rollGreater() roll success}} {{#^rollGreater() roll success}} {{#rollTotal() roll 20}} <td class="sheet-rolltemplate-skillRoll-template_value">Failure</td> {{/rollTotal() roll 20}} <!-- Success --> {{#^rollTotal() roll 20}} <td class="sheet-rolltemplate-skillRoll-template_value">Success</td> {{/^rollTotal() roll 20}} {{/^rollGreater() roll success}} {{/rollLess() roll cf}} {{/rollGreater() roll os}} {{#^rollLess() roll cf}} <!--Catastrophic Failure: --> <td class="sheet-rolltemplate-skillRoll-template_value">Catastrophic Failure</td> {{/^rollLess() roll cf}} </tr> </table> </rolltemplate> And this is a current roll-button, which I've changed slightly since it is now in a repeating section: <button type="roll" name="roll_strskill" value="&{template:skillRoll} {{name=@{Name}}} {{skillvalue=@{strskillValue}}} {{os=[[((@{strskillValue}+@{Strength})*?{Difficulty?|Average,[[2]]|Easy,[[4]]|Difficult,[[1]]|Formidable,[[0.5]]|Impossible,[[0.25]]})-10]]}} {{cf=[[((@{strskillValue}+@{Strength})*?{Difficulty?| Average,[[2]]|Easy, [[4]] |Difficult,[[1]]|Formidable,[[0.5]]|Impossible,[[0.25]] })+10]]}} {{success=[[(@{strskillValue}+@{Strength})*?{Difficulty?| Average,[[2]]|Easy, [[4]] |Difficult,[[1]]|Formidable,[[0.5]]|Impossible,[[0.25]] }]]}} {{roll=[[1d20]]}} {{skillname=@{strskillName}}}"></button>
1588936350
GiGs
Pro
Sheet Author
API Scripter
The problem is, you cant do calculations within the rolltemplate code. It has to be done in the macro itself before sending to the rolltemplate. So unfortunately you cant move that into the rolltemplate.
Well, that saved me a lot of time :)