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

shortening a duplicate part of a rolltemplate

1680595196
Matthew C
Pro
Sheet Author
Ok, so for my system the character can roll a number of dice like 5d10 and it would show up as 5 times a single d10, but for roll templates this is a hell (at least to visually show it. I have the following code (warning very long, multiple posts) and I really wish I could do this in a foreach loop as each minor change requires a lot of places to change and is very easy to break < rolltemplate class = "sheet-rolltemplate-actionroll" >     < div class= "sheet-template-container" >         < div class= "sheet-template-header" > {{ name }} </ div >         {{ #primary }} < div class= "sheet-template-column" style= "text-align: center;" > {{ primary }} </ div > {{ /primary }}         < div class= "sheet-template-span sheet-template-wrap" >             {{ #rollGreater () number 0 }}             < div class= "sheet-template-inner-container" >                 {{ #rollTotal () reroll 0 }} < span class= "sheet-template-roll" > {{ computed :: roll1 }} < span class= "sheet-template-roll-backing" > 0 </ span ></ span > {{ /rollTotal () reroll 0 }}                 {{ #rollTotal () reroll 1 }}{{ #^ rollGreater () honed 0 }} < span class= "sheet-template-roll" > {{ computed :: roll1 }} < span class= "sheet-template-roll-backing" > 0 </ span ></ span > {{ / ^ rollGreater () honed 0 }}{{ /rollTotal () reroll 1 }}                 {{ #rollTotal () reroll 1 }}                 {{ #rollGreater () honed 0 }}                 < span class= "sheet-template-roll" >                     < span class= "sheet-template-roll" > {{ computed :: roll1 }}                         {{ #rollTotal () computed :: greater1 0 }} < span class= "sheet-template-roll-backing-crit" > 0 </ span > {{ /rollTotal () computed::greater1 0 }}                         {{ #rollTotal () computed :: greater1 1 }} < span class= "sheet-template-roll-backing-fail" > 0 </ span > {{ /rollTotal () computed::greater1 1 }}                     </ span >                     < span class= "sheet-template-roll" > {{ computed :: reRoll1 }}                         {{ #rollTotal () computed :: greater1 0 }} < span class= "sheet-template-roll-backing-fail" > 0 </ span > {{ /rollTotal () computed::greater1 0 }}                         {{ #rollTotal () computed :: greater1 1 }} < span class= "sheet-template-roll-backing-crit" > 0 </ span > {{ /rollTotal () computed::greater1 1 }}                     </ span >                 </ span >                 </ span >                 {{ /rollGreater () honed 0 }}                 {{ /rollTotal () reroll 1 }}                 < div class= "sheet-template-column" >                     < span class= "sheet-template-bonus" >< span class= "sheet-template-bonus-plus" > + </ span > {{ bonus }} </ span >                     < span class= "sheet-template-bonus" >< span class= "sheet-template-bonus-plus" > - </ span > {{ penalty }} </ span >                 </ div >                 < span class= "sheet-template-roll-fix" > {{ computed :: result1 }} < span class= "sheet-template-result-backing" > t </ span ></ span >             </ div >             {{ /rollGreater () number 0 }}             {{ #rollGreater () number 1 }}             < div class= "sheet-template-inner-container" >                 {{ #rollTotal () reroll 0 }} < span class= "sheet-template-roll" > {{ computed :: roll2 }} < span class= "sheet-template-roll-backing" > 0 </ span ></ span > {{ /rollTotal () reroll 0 }}                 {{ #rollTotal () reroll 1 }}{{ #^ rollGreater () honed 1 }} < span class= "sheet-template-roll" > {{ computed :: roll2 }} < span class= "sheet-template-roll-backing" > 0 </ span ></ span > {{ / ^ rollGreater () honed 1 }}{{ /rollTotal () reroll 1 }}                 {{ #rollTotal () reroll 1 }}                 {{ #rollGreater () honed 1 }}                 < span class= "sheet-template-roll" >                     < span class= "sheet-template-roll" > {{ computed :: roll2 }}                         {{ #rollTotal () computed :: greater2 0 }} < span class= "sheet-template-roll-backing-crit" > 0 </ span > {{ /rollTotal () computed::greater2 0 }}                         {{ #rollTotal () computed :: greater2 1 }} < span class= "sheet-template-roll-backing-fail" > 0 </ span > {{ /rollTotal () computed::greater2 1 }}                     </ span >                     < span class= "sheet-template-roll" > {{ computed :: reRoll2 }}                         {{ #rollTotal () computed :: greater2 0 }} < span class= "sheet-template-roll-backing-fail" > 0 </ span > {{ /rollTotal () computed::greater2 0 }}                         {{ #rollTotal () computed :: greater2 1 }} < span class= "sheet-template-roll-backing-crit" > 0 </ span > {{ /rollTotal () computed::greater2 1 }}                     </ span >                 </ span >                 </ span >                 {{ /rollGreater () honed 1 }}                 {{ /rollTotal () reroll 1 }}                 < div class= "sheet-template-column" >                     < span class= "sheet-template-bonus" >< span class= "sheet-template-bonus-plus" > + </ span > {{ bonus }} </ span >                     < span class= "sheet-template-bonus" >< span class= "sheet-template-bonus-plus" > - </ span > {{ penalty }} </ span >                 </ div >                 < span class= "sheet-template-roll-fix" > {{ computed :: result2 }} < span class= "sheet-template-result-backing" > t </ span ></ span >             </ div >             {{ /rollGreater () number 1 }}             {{ #rollGreater () number 2 }}             < div class= "sheet-template-inner-container" >                 {{ #rollTotal () reroll 0 }} < span class= "sheet-template-roll" > {{ computed :: roll3 }} < span class= "sheet-template-roll-backing" > 0 </ span ></ span > {{ /rollTotal () reroll 0 }}                 {{ #rollTotal () reroll 1 }}{{ #^ rollGreater () honed 2 }} < span class= "sheet-template-roll" > {{ computed :: roll3 }} < span class= "sheet-template-roll-backing" > 0 </ span ></ span > {{ / ^ rollGreater () honed 2 }}{{ /rollTotal () reroll 1 }}                 {{ #rollTotal () reroll 1 }}                 {{ #rollGreater () honed 2 }}                 < span class= "sheet-template-roll" >                     < span class= "sheet-template-roll" > {{ computed :: roll3 }}                         {{ #rollTotal () computed :: greater3 0 }} < span class= "sheet-template-roll-backing-crit" > 0 </ span > {{ /rollTotal () computed::greater2 0 }}                         {{ #rollTotal () computed :: greater3 1 }} < span class= "sheet-template-roll-backing-fail" > 0 </ span > {{ /rollTotal () computed::greater2 1 }}                     </ span >                     < span class= "sheet-template-roll" > {{ computed :: reRoll3 }}                         {{ #rollTotal () computed :: greater3 0 }} < span class= "sheet-template-roll-backing-fail" > 0 </ span > {{ /rollTotal () computed::greater2 0 }}                         {{ #rollTotal () computed :: greater3 1 }} < span class= "sheet-template-roll-backing-crit" > 0 </ span > {{ /rollTotal () computed::greater2 1 }}                     </ span >                 </ span >                 </ span >                 {{ /rollGreater () honed 2 }}                 {{ /rollTotal () reroll 1 }}                 < div class= "sheet-template-column" >                     < span class= "sheet-template-bonus" >< span class= "sheet-template-bonus-plus" > + </ span > {{ bonus }} </ span >                     < span class= "sheet-template-bonus" >< span class= "sheet-template-bonus-plus" > - </ span > {{ penalty }} </ span >                 </ div >                 < span class= "sheet-template-roll-fix" > {{ computed :: result3 }} < span class= "sheet-template-result-backing" > t </ span ></ span >             </ div >             {{ /rollGreater () number 2 }}
1680595282
Matthew C
Pro
Sheet Author
{{ #rollGreater () number 3 }}             < div class= "sheet-template-inner-container" >                 {{ #rollTotal () reroll 0 }} < span class= "sheet-template-roll" > {{ computed :: roll4 }} < span class= "sheet-template-roll-backing" > 0 </ span ></ span > {{ /rollTotal () reroll 0 }}                 {{ #rollTotal () reroll 1 }}{{ #^ rollGreater () honed 3 }} < span class= "sheet-template-roll" > {{ computed :: roll4 }} < span class= "sheet-template-roll-backing" > 0 </ span ></ span > {{ / ^ rollGreater () honed 3 }}{{ /rollTotal () reroll 1 }}                 {{ #rollTotal () reroll 1 }}                 {{ #rollGreater () honed 3 }}                 < span class= "sheet-template-roll" >                     < span class= "sheet-template-roll" > {{ computed :: roll4 }}                         {{ #rollTotal () computed :: greater4 0 }} < span class= "sheet-template-roll-backing-crit" > 0 </ span > {{ /rollTotal () computed::greater2 0 }}                         {{ #rollTotal () computed :: greater4 1 }} < span class= "sheet-template-roll-backing-fail" > 0 </ span > {{ /rollTotal () computed::greater2 1 }}                     </ span >                     < span class= "sheet-template-roll" > {{ computed :: reRoll4 }}                         {{ #rollTotal () computed :: greater4 0 }} < span class= "sheet-template-roll-backing-fail" > 0 </ span > {{ /rollTotal () computed::greater2 0 }}                         {{ #rollTotal () computed :: greater4 1 }} < span class= "sheet-template-roll-backing-crit" > 0 </ span > {{ /rollTotal () computed::greater2 1 }}                     </ span >                 </ span >                 </ span >                 {{ /rollGreater () honed 3 }}                 {{ /rollTotal () reroll 1 }}                 < div class= "sheet-template-column" >                     < span class= "sheet-template-bonus" >< span class= "sheet-template-bonus-plus" > + </ span > {{ bonus }} </ span >                     < span class= "sheet-template-bonus" >< span class= "sheet-template-bonus-plus" > - </ span > {{ penalty }} </ span >                 </ div >                 < span class= "sheet-template-roll-fix" > {{ computed :: result4 }} < span class= "sheet-template-result-backing" > t </ span ></ span >             </ div >             {{ /rollGreater () number 3 }}             {{ #rollGreater () number 4 }}             < div class= "sheet-template-inner-container" >                 {{ #rollTotal () reroll 0 }} < span class= "sheet-template-roll" > {{ computed :: roll5 }} < span class= "sheet-template-roll-backing" > 0 </ span ></ span > {{ /rollTotal () reroll 0 }}                 {{ #rollTotal () reroll 1 }}{{ #^ rollGreater () honed 4 }} < span class= "sheet-template-roll" > {{ computed :: roll5 }} < span class= "sheet-template-roll-backing" > 0 </ span ></ span > {{ / ^ rollGreater () honed 4 }}{{ /rollTotal () reroll 1 }}                 {{ #rollTotal () reroll 1 }}                 {{ #rollGreater () honed 4 }}                 < span class= "sheet-template-roll" >                     < span class= "sheet-template-roll" > {{ computed :: roll5 }}                         {{ #rollTotal () computed :: greater5 0 }} < span class= "sheet-template-roll-backing-crit" > 0 </ span > {{ /rollTotal () computed::greater2 0 }}                         {{ #rollTotal () computed :: greater5 1 }} < span class= "sheet-template-roll-backing-fail" > 0 </ span > {{ /rollTotal () computed::greater2 1 }}                     </ span >                     < span class= "sheet-template-roll" > {{ computed :: reRoll5 }}                         {{ #rollTotal () computed :: greater5 0 }} < span class= "sheet-template-roll-backing-fail" > 0 </ span > {{ /rollTotal () computed::greater2 0 }}                         {{ #rollTotal () computed :: greater5 1 }} < span class= "sheet-template-roll-backing-crit" > 0 </ span > {{ /rollTotal () computed::greater2 1 }}                     </ span >                 </ span >                 </ span >                 {{ /rollGreater () honed 4 }}                 {{ /rollTotal () reroll 1 }}                 < div class= "sheet-template-column" >                     < span class= "sheet-template-bonus" >< span class= "sheet-template-bonus-plus" > + </ span > {{ bonus }} </ span >                     < span class= "sheet-template-bonus" >< span class= "sheet-template-bonus-plus" > - </ span > {{ penalty }} </ span >                 </ div >                 < span class= "sheet-template-roll-fix" > {{ computed :: result5 }} < span class= "sheet-template-result-backing" > t </ span ></ span >             </ div >             {{ /rollGreater () number 4 }}             {{ #rollGreater () number 5 }}             < div class= "sheet-template-inner-container" >                 {{ #rollTotal () reroll 0 }} < span class= "sheet-template-roll" > {{ computed :: roll6 }} < span class= "sheet-template-roll-backing" > 0 </ span ></ span > {{ /rollTotal () reroll 0 }}                 {{ #rollTotal () reroll 1 }}{{ #^ rollGreater () honed 5 }} < span class= "sheet-template-roll" > {{ computed :: roll6 }} < span class= "sheet-template-roll-backing" > 0 </ span ></ span > {{ / ^ rollGreater () honed 5 }}{{ /rollTotal () reroll 1 }}                 {{ #rollTotal () reroll 1 }}                 {{ #rollGreater () honed 5 }}                 < span class= "sheet-template-roll" >                     < span class= "sheet-template-roll" > {{ computed :: roll6 }}                         {{ #rollTotal () computed :: greater6 0 }} < span class= "sheet-template-roll-backing-crit" > 0 </ span > {{ /rollTotal () computed::greater2 0 }}                         {{ #rollTotal () computed :: greater6 1 }} < span class= "sheet-template-roll-backing-fail" > 0 </ span > {{ /rollTotal () computed::greater2 1 }}                     </ span >                     < span class= "sheet-template-roll" > {{ computed :: reRoll6 }}                         {{ #rollTotal () computed :: greater6 0 }} < span class= "sheet-template-roll-backing-fail" > 0 </ span > {{ /rollTotal () computed::greater2 0 }}                         {{ #rollTotal () computed :: greater6 1 }} < span class= "sheet-template-roll-backing-crit" > 0 </ span > {{ /rollTotal () computed::greater2 1 }}                     </ span >                 </ span >                 </ span >                 {{ /rollGreater () honed 5 }}                 {{ /rollTotal () reroll 1 }}                 < div class= "sheet-template-column" >                     < span class= "sheet-template-bonus" >< span class= "sheet-template-bonus-plus" > + </ span > {{ bonus }} </ span >                     < span class= "sheet-template-bonus" >< span class= "sheet-template-bonus-plus" > - </ span > {{ penalty }} </ span >                 </ div >                 < span class= "sheet-template-roll-fix" > {{ computed :: result6 }} < span class= "sheet-template-result-backing" > t </ span ></ span >             </ div >             {{ /rollGreater () number 5 }}
1680595385
Matthew C
Pro
Sheet Author
The following continues to #rollgreater() number 19 just to give an idea of how huge this is and ends with < div class= "sheet-template-span sheet-template-wrap" >             {{ #rollGreater () number 20 }}             Template only shows 20 dice             {{ /rollGreater () number 20 }}             {{ computed :: test }}         </ div >         {{ #rollTotal () reroll 0 }}         < span class= "sheet-template-span" style= "font-weight: 100;" >             [Re-Roll - Honed](~ {{ character }} |honed|| {{ computed :: passthrough }} )             [Re-Roll - Muted](~ {{ character }} |muted|| {{ computed :: passthrough }} )         </ span >         < span class= "sheet-template-row-outcome" style= "font-weight: 100;" >             Re-Rolling either Honed or Muted will only roll the second dice and compare them to the original         </ span >         {{ /rollTotal () reroll 0 }}     </ div >     {{ #rollTotal () computed :: iscritorfail 1 }}     < div class= "sheet-template-container" >         {{ #rollTotal () computed :: crit 1 }}         < div class= "sheet-template-header" > Overwhelming </ div >         < span class= "sheet-template-columned" >             {{ #rollTotal () computed :: type 1 }} < span style= "text-align: center;" > Re-roll a single failed Wound Dice, this re-roll is never Muted or Honed. </ span > {{ /rollTotal () computed::type 1 }}             {{ #rollTotal () computed :: type 2 }} < span style= "text-align: center;" > Gain an additional Wound Die, this Die is never Muted or Honed. </ span > {{ /rollTotal () computed::type 2 }}             {{ #rollTotal () computed :: type 3 }} < span style= "text-align: center;" > Gain an additional Alleviation Die, this Die is never Muted or Honed. </ span > {{ /rollTotal () computed::type 3 }}         </ span >         {{ /rollTotal () computed::crit 1 }}         {{ #rollGreater () computed :: crit 1 }}         < div class= "sheet-template-header" > Critical Success </ div >         < span class= "sheet-template-columned" >             {{ #rollTotal () computed :: type 1 }} < span style= "text-align: center;" > Negate a single Wound. </ span > {{ /rollTotal () computed::type 1 }}             {{ #rollTotal () computed :: type 2 }} < span style= "text-align: center;" > Cause a single Wound. </ span > {{ /rollTotal () computed::type 2 }}             {{ #rollTotal () computed :: type 3 }} < span style= "text-align: center;" > Recover a single Wound. </ span > {{ /rollTotal () computed::type 3 }}         </ span >         {{ /rollGreater () computed::crit 1 }}     </ div >     {{ /rollTotal () computed::iscritorfail 1 }}     {{ #rollTotal () computed :: iscritorfail -1 }}     < div class= "sheet-template-container" >         {{ #rollTotal () computed :: fail 1 }}         < div class= "sheet-template-header" > Underwhelming </ div >         < span class= "sheet-template-columned" >             {{ #rollTotal () computed :: type 1 }} < span style= "text-align: center;" > You suffer an additional Wound Dice, this Die is never Muted or Honed. </ span > {{ /rollTotal () computed::type 1 }}             {{ #rollTotal () computed :: type 2 }} < span style= "text-align: center;" > Re-roll a single successful Wound Dice, this re-roll is never Muted or Honed. </ span > {{ /rollTotal () computed::type 2 }}             {{ #rollTotal () computed :: type 3 }} < span style= "text-align: center;" > Re-roll a single successful Alleviation Dice, this re-roll is never Muted or Honed. </ span > {{ /rollTotal () computed::type 3 }}         </ span >         {{ /rollTotal () computed::fail 1 }}         {{ #rollGreater () computed :: fail 1 }}         < div class= "sheet-template-header" > Critical Failure </ div >         < span class= "sheet-template-columned" >             {{ #rollTotal () computed :: type 1 }} < span style= "text-align: center;" > You suffer a single Wound. </ span > {{ /rollTotal () computed::type 1 }}             {{ #rollTotal () computed :: type 2 }} < span style= "text-align: center;" > Negate a single successful Wound Dice. </ span > {{ /rollTotal () computed::type 2 }}             {{ #rollTotal () computed :: type 3 }} < span style= "text-align: center;" > Negate a single successful Alleviation Dice. </ span > {{ /rollTotal () computed::type 3 }}         </ span >         {{ /rollGreater () computed::fail 1 }}     </ div >     {{ /rollTotal () computed::iscritorfail -1 }}     {{ #rollGreater () computed :: effect 0 }}     < div class= "sheet-template-container" >         < div class= "sheet-template-header" > Effect Runes </ div >         < span class= "sheet-template-columned" >             < span > {{ effectone }} </ span >             < span > {{ effecttwo }} </ span >             < span > {{ effectthree }} </ span >         </ span >     </ div >     {{ /rollGreater () computed::effect 0 }} </ rolltemplate >
1680609146
GiGs
Pro
Sheet Author
API Scripter
If you want to cutdown the rolltemplate duplication, the way to go is to use Custom Roll Parsing - you can handle all duplication in there via loops, build an output string, and need far less coding in the rolltemplate itself.