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

strange rolltemplate issue with a bunch of copies

1679936085
Matthew C
Pro
Sheet Author
I am at a complete loss &lt; rolltemplate class = "sheet-rolltemplate-mitigation" &gt; &nbsp; &nbsp; &lt; div class= "sheet-template-container" &gt; &nbsp; &nbsp; &nbsp; &nbsp; &lt; div class= "sheet-template-header" &gt; {{ name }} &lt;/ div &gt; &nbsp; &nbsp; &nbsp; &nbsp; &lt; div class= "sheet-template-span sheet-template-wrap" &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {{ #rollGreater () number 0 }} &lt; span class= "sheet-template-roll" &gt; {{ computed :: result1 }} &lt; span class= "sheet-template-roll-backing" &gt; 0 &lt;/ span &gt;&lt;/ span &gt; {{ /rollGreater () number 0 }} &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {{ #rollGreater () number 1 }} &lt; span class= "sheet-template-roll" &gt; {{ computed :: result2 }} &lt; span class= "sheet-template-roll-backing" &gt; 0 &lt;/ span &gt;&lt;/ span &gt; {{ /rollGreater () number 1 }} &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {{ #rollGreater () number 2 }} &lt; span class= "sheet-template-roll" &gt; {{ computed :: result3 }} &lt; span class= "sheet-template-roll-backing" &gt; 0 &lt;/ span &gt;&lt;/ span &gt; {{ /rollGreater () number 2 }} &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {{ #rollGreater () number 3 }} &lt; span class= "sheet-template-roll" &gt; {{ computed :: result4 }} &lt; span class= "sheet-template-roll-backing" &gt; 0 &lt;/ span &gt;&lt;/ span &gt; {{ /rollGreater () number 3 }} &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {{ #rollGreater () number 4 }} &lt; span class= "sheet-template-roll" &gt; {{ computed :: result5 }} &lt; span class= "sheet-template-roll-backing" &gt; 0 &lt;/ span &gt;&lt;/ span &gt; {{ /rollGreater () number 4 }} &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {{ #rollGreater () number 5 }} &lt; span class= "sheet-template-roll" &gt; {{ computed :: result6 }} &lt; span class= "sheet-template-roll-backing" &gt; 0 &lt;/ span &gt;&lt;/ span &gt; {{ /rollGreater () number 5 }} &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {{ #rollGreater () number 6 }} &lt; span class= "sheet-template-roll" &gt; {{ computed :: result7 }} &lt; span class= "sheet-template-roll-backing" &gt; 0 &lt;/ span &gt;&lt;/ span &gt; {{ /rollGreater () number 6 }} &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {{ #rollGreater () number 7 }} &lt; span class= "sheet-template-roll" &gt; {{ computed :: result8 }} &lt; span class= "sheet-template-roll-backing" &gt; 0 &lt;/ span &gt;&lt;/ span &gt; {{ /rollGreater () number 7 }} &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {{ #rollGreater () number 8 }} &lt; span class= "sheet-template-roll" &gt; {{ computed :: result9 }} &lt; span class= "sheet-template-roll-backing" &gt; 0 &lt;/ span &gt;&lt;/ span &gt; {{ /rollGreater () number 8 }} &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {{ #rollGreater () number 9 }} &lt; span class= "sheet-template-roll" &gt; {{ computed :: result10 }} &lt; span class= "sheet-template-roll-backing" &gt; 0 &lt;/ span &gt;&lt;/ span &gt; {{ /rollGreater () number 9 }} &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {{ #rollGreater () number 10 }} &lt; span class= "sheet-template-roll" &gt; {{ computed :: result11 }} &lt; span class= "sheet-template-roll-backing" &gt; 0 &lt;/ span &gt;&lt;/ span &gt; {{ /rollGreater () number 10 }} &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {{ #rollGreater () number 11 }} &lt; span class= "sheet-template-roll" &gt; {{ computed :: result12 }} &lt; span class= "sheet-template-roll-backing" &gt; 0 &lt;/ span &gt;&lt;/ span &gt; {{ /rollGreater () number 11 }} &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {{ #rollGreater () number 12 }} &lt; span class= "sheet-template-roll" &gt; {{ computed :: result13 }} &lt; span class= "sheet-template-roll-backing" &gt; 0 &lt;/ span &gt;&lt;/ span &gt; {{ /rollGreater () number 12 }} &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {{ #rollGreater () number 13 }} &lt; span class= "sheet-template-roll" &gt; {{ computed :: result14 }} &lt; span class= "sheet-template-roll-backing" &gt; 0 &lt;/ span &gt;&lt;/ span &gt; {{ /rollGreater () number 13 }} &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {{ #rollGreater () number 14 }} &lt; span class= "sheet-template-roll" &gt; {{ computed :: result15 }} &lt; span class= "sheet-template-roll-backing" &gt; 0 &lt;/ span &gt;&lt;/ span &gt; {{ /rollGreater () number 14 }} &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {{ #rollGreater () number 15 }} &lt; span class= "sheet-template-roll" &gt; {{ computed :: result16 }} &lt; span class= "sheet-template-roll-backing" &gt; 0 &lt;/ span &gt;&lt;/ span &gt; {{ /rollGreater () number 15 }} &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {{ #rollGreater () number 16 }} &lt; span class= "sheet-template-roll" &gt; {{ computed :: result17 }} &lt; span class= "sheet-template-roll-backing" &gt; 0 &lt;/ span &gt;&lt;/ span &gt; {{ /rollGreater () number 16 }} &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {{ #rollGreater () number 17 }} &lt; span class= "sheet-template-roll" &gt; {{ computed :: result18 }} &lt; span class= "sheet-template-roll-backing" &gt; 0 &lt;/ span &gt;&lt;/ span &gt; {{ /rollGreater () number 17 }} &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {{ #rollGreater () number 18 }} &lt; span class= "sheet-template-roll" &gt; {{ computed :: result19 }} &lt; span class= "sheet-template-roll-backing" &gt; 0 &lt;/ span &gt;&lt;/ span &gt; {{ /rollGreater () number 18 }} &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {{ #rollGreater () number 19 }} &lt; span class= "sheet-template-roll" &gt; {{ computed :: result20 }} &lt; span class= "sheet-template-roll-backing" &gt; 0 &lt;/ span &gt;&lt;/ span &gt; {{ /rollGreater () number 19 }} &nbsp; &nbsp; &nbsp; &nbsp; &lt;/ div &gt; &nbsp; &nbsp; &lt;/ div &gt; &lt;/ rolltemplate &gt; As you can see, each of these is an identical copy, so if one works, they should all work...yet the 11th one is broken <a href="https://imgur.com/NO2ezQp" rel="nofollow">https://imgur.com/NO2ezQp</a> here is an image of the strange issue, I have no clue why this is happening
1679942186
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
This looks like a css error or js error (if you're using custom roll parsing) to me. I'd recommend the following troubleshooting steps: inspect the roll template output and see if the result is actually output there Check your css to ensure there isn't some weird nth-child declaration that is causing an issue or something If using CRP, then check your roll function(s) to ensure that result11 is actually being sent.
1679947143
GiGs
Pro
Sheet Author
API Scripter
Also is it specifically the 11th one that;s broken, or is it broken for every one after that? If its just the 11th, I'd be thinking as Scott is, and looking specifically at what is different with that one result.
1680014298
Matthew C
Pro
Sheet Author
Hey guys, thanks for the responses, I found it, after checking the sheetworker as well for the 100th time I finally noticed in the string call for the actual roll, I made 2x roll10 so there was no roll11...I really hate it when it is the simple things that get you XD
1680030396
GiGs
Pro
Sheet Author
API Scripter
hehe, they really do. Though if you have 20 almost identical calls, it would be a good idea to do the calculations with a loop and avoid that risk.
1680104929
Matthew C
Pro
Sheet Author
Well, is there a better way to do this? on ( 'clicked:mitigationroll' , ( info ) =&gt; { &nbsp; &nbsp; &nbsp; &nbsp; let endroll = "&amp;{template:mitigation} {{name=@{character_name}'s Mitigation Roll}} {{number=[[?{number of Wound Dice|0}]]}}" + &nbsp; &nbsp; &nbsp; &nbsp; "{{roll=[[?{number of Wound Dice|0}d10]]}}" + &nbsp; &nbsp; &nbsp; &nbsp; "{{roll1=[[0]]}} {{roll2=[[0]]}} {{roll3=[[0]]}} {{roll4=[[0]]}} {{roll5=[[0]]}} {{roll6=[[0]]}} {{roll7=[[0]]}} {{roll8=[[0]]}} {{roll9=[[0]]}} {{roll10=[[0]]}} " + &nbsp; &nbsp; &nbsp; &nbsp; "{{roll11=[[0]]}} {{roll12=[[0]]}} {{roll13=[[0]]}} {{roll14=[[0]]}} {{roll15=[[0]]}} {{roll16=[[0]]}} {{roll17=[[0]]}} {{roll18=[[0]]}} {{roll19=[[0]]}} {{roll20=[[0]]}} " + &nbsp; &nbsp; &nbsp; &nbsp; "{{result1=[[0]]}} {{result2=[[0]]}} {{result3=[[0]]}} {{result4=[[0]]}} {{result5=[[0]]}} {{result6=[[0]]}} {{result7=[[0]]}} {{result8=[[0]]}} {{result9=[[0]]}} {{result10=[[0]]}} " + &nbsp; &nbsp; &nbsp; &nbsp; "{{result11=[[0]]}} {{result12=[[0]]}} {{result13=[[0]]}} {{result14=[[0]]}} {{result15=[[0]]}} {{result16=[[0]]}} {{result17=[[0]]}} {{result18=[[0]]}} {{result19=[[0]]}} {{result20=[[0]]}} " + &nbsp; &nbsp; &nbsp; &nbsp; "{{character=@{character_name}}} {{bonus=[[?{Bonus|0} [Bonus] + @{passive_mitigation} [Mitigation] ]]}} {{penalty=[[?{Penalty|0} [Penalty]]]}}" ; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; startRoll ( endroll , ( results ) =&gt; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; let roll = []; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; let result = []; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; let number = results . results . number . result ; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for ( let i = 0 ; i &lt; number ; i ++) { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; roll [ i ] = results . results . roll . dice [ i ]; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result [ i ] = results . results . roll . dice [ i ] + results . results . bonus . result - results . results . penalty . result ; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; finishRoll ( &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; results . rollId , { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; roll1: roll [ 0 ], &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; roll2: roll [ 1 ], &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; roll3: roll [ 2 ], &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; roll4: roll [ 3 ], &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; roll5: roll [ 4 ], &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; roll6: roll [ 5 ], &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; roll7: roll [ 6 ], &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; roll8: roll [ 7 ], &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; roll9: roll [ 8 ], &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; roll10: roll [ 9 ], &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; roll11: roll [ 10 ], &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; roll12: roll [ 11 ], &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; roll13: roll [ 12 ], &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; roll14: roll [ 13 ], &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; roll15: roll [ 14 ], &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; roll16: roll [ 15 ], &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; roll17: roll [ 16 ], &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; roll18: roll [ 17 ], &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; roll19: roll [ 18 ], &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; roll20: roll [ 19 ], &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result1: result [ 0 ], &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result2: result [ 1 ], &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result3: result [ 2 ], &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result4: result [ 3 ], &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result5: result [ 4 ], &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result6: result [ 5 ], &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result7: result [ 6 ], &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result8: result [ 7 ], &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result9: result [ 8 ], &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result10: result [ 9 ], &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result11: result [ 10 ], &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result12: result [ 11 ], &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result13: result [ 12 ], &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result14: result [ 13 ], &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result15: result [ 14 ], &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result16: result [ 15 ], &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result17: result [ 16 ], &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result18: result [ 17 ], &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result19: result [ 18 ], &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result20: result [ 19 ] &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }); &nbsp; &nbsp; &nbsp; &nbsp; }); &nbsp; &nbsp; }); because, I really hate these long things, they are too easy to break
1680114355

Edited 1680204301
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
yes, you'd do it in a loop. This should be equivalent with some streamlining of the code: on('clicked:mitigationroll', (info) =&gt; { // Create your base roll details. let endRoll = "&amp;{template:mitigation} {{name=@{character_name}'s Mitigation Roll}} {{number=[[?{number of Wound Dice|0}]]}} {{roll=[[?{number of Wound Dice|0}d10]]}} {{character=@{character_name}}} {{bonus=[[?{Bonus|0} [Bonus] + @{passive_mitigation} [Mitigation] ]]}} {{penalty=[[?{Penalty|0} [Penalty]]]}}"; // The below is equivalent to doing the long hand written string you had. // create an array that starts at 1 and goes to the max you need const numArr = [...Array(20).keys()].map(n =&gt; n + 1); //This is really just the native version of _.range(1,20) using the underscore library, but I've been trying to get away from using underscore // Iterate over an array of the length you need and add each roll field numArr.forEach(n =&gt; endRoll += `{{roll${n}=[[0]]}} `); //Use template literals to make string concatenation easier to read and work with. // I'd really recommend using the async/await pattern with startRoll instead of the callback, but that's a bigger topic than I want to add on to an existing question. startRoll(endRoll, (results) =&gt; { // create an empty object that will hold our computed rolls details const computeObj = {}; let number = results.results.number.result; // Switched this to just use a forEach to run through the dice array instead results.results.roll.dice.forEach((dieResult,i) =&gt; { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Add the roll and result field for each relevant die to the computedObj. computedObj[`roll${i + 1}`] = dieResult; computedObj[`result${i + 1}`] = dieResult + results.results.bonus.result - results.results.penalty.result; }) finishRoll(results.rollId, computedObj); }); });
1680192340
Matthew C
Pro
Sheet Author
Hey thanks a bunch, but I think this might need to be async (although I have never worked with that before) since I get the following: ReferenceError: endroll is not defined &nbsp; &nbsp; at Array.eval (eval at messageHandler (sheetsandboxworker.js:732:1), &lt;anonymous&gt;:192:15) &nbsp; &nbsp; at self.trigger (sheetsandboxworker.js:148:1) &nbsp; &nbsp; at messageHandler (sheetsandboxworker.js:735:1)
1680204263

Edited 1680204319
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
It's because I camelcased the definition, but forgot to edit the use of it in the start roll call. Edit: I've edited the code to fix that issue.
1680279579
Matthew C
Pro
Sheet Author
Hey thanks again, I am feeling very stupid right about now XD it is working perfectly (after renaming computeObj ro computedObj) :p