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

Formatting background colour based on result

1492725893
AquaAlex
Sheet Author
Translator
API Scripter
Ok so i want to change the roll template so that the last row has different colours depending on result For instance in the code below I would like a Critical result have a Green background for the row, a Fumble must have a Red background, etc. Can I do this? And  what is the best way to do it? <rolltemplate class="sheet-rolltemplate-coc-attack">     <table>         <caption>{{name}}</caption>         <tr><td class="template_label">Value:</td><td class="template_value">{{success}}/{{hard}}/{{extreme}}</td></tr>         {{#malf}}             <tr><td class="template_label">Malf:</td><td class="template_value">{{malf}}</td></tr>         {{/malf}}         <tr><td class="template_label">Rolled:</td><td class="template_value">{{roll1}}</td></tr>         <tr style="background:#DFF0D8;">             <td class="template_label">Result:</td>                 <!-- 01 is always Critical -->                 {{#rollTotal() roll1 1}}                    <td class="template_value"><b>Critical</b></td>                 {{/rollTotal() roll1 1}}                  <!-- Is Success -->                 {{#rollBetween() roll1 2 success}}                   <!-- Is Standard -->                   {{#rollGreater() roll1 hard}}                     <td class="template_value">Success</td>                   {{/rollGreater() roll1 hard}}                   <!-- Is Hard or Extreme -->                   {{#rollBetween() roll1 2 hard}}                     <!-- Is Hard -->                     {{#rollGreater() roll1 extreme}}                       <td class="template_value">Hard</td>                     {{/rollGreater() roll1 extreme}}                     <!-- Is Extreme -->                     {{#rollBetween() roll1 2 extreme}}                       <td class="template_value"><b>Extreme</b></td>                     {{/rollBetween() roll1 2 extreme}}                   {{/rollBetween() roll1 2 hard}}                 {{/rollBetween() roll1 2 success}}                 <!-- Is Not Success -->                 {{#rollGreater() roll1 success}}                   <!-- Is skill >= 50 -->                   {{#rollGreater() success 49}}                     <!-- Is Fumble -->                     {{#rollTotal() roll1 100}}                        <td class="template_value"><b>Fumble</b></td>                     {{/rollTotal() roll1 100}}                      <!-- Is Fail -->                     {{#rollLess() roll1 100}}                       <td class="template_value">Fail</td>                     {{/rollLess() roll1 100}}                   {{/rollGreater() success 49}}                   <!-- Is skill < 50 -->                   {{#rollLess() success 50}}                     <!-- Is Fumble -->                     {{#rollGreater() roll1 95}}                       <td class="template_value"><b>Fumble</b></td>                     {{/rollGreater() roll1 95}}                     <!-- Is Fail -->                     {{#rollLess() roll1 96}}                       <td class="template_value">Fail</td>                     {{/rollLess() roll1 96}}                   {{/rollLess() success 50}}                 {{/rollGreater() roll1 success}}         </tr>         <tr> <td class="template_label">Dam:</td><td class="template_value">{{damage}}</td> </tr>     </table> </rolltemplate>
1492738562
Lithl
Pro
Sheet Author
API Scripter
You look like you've already got the hang of using rollTotal, rollLess, rollGreater, and rollBetween to distinguish between crist/fumbles/neither in the template. Use the same logic to add an appropriate class to your <tr>.