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

Custom Roll Parsing: Broken rollTotal(), broken strings?

1629308541
Isurandil
Pro
Sheet Author
Minimal Working Example: &lt;div&gt;&lt;button type="action" name="act_test"&gt;Click me&lt;/button&gt;&lt;/div&gt; &lt;rolltemplate class="sheet-rolltemplate-test"&gt; &lt;h4&gt;Uncomputed: {{text}}/{{roll1}}&lt;/h4&gt; {{#rollTotal() roll1 1}}&lt;div&gt;Roll Total 1&lt;/div&gt;{{/rollTotal() roll1 1}} {{#rollLess() roll1 2}}&lt;div&gt;Roll Less 2&lt;/div&gt;{{/rollLess() roll1 2}} {{#rollGreater() roll1 2}}&lt;div&gt;Roll Greater 2&lt;/div&gt;{{/rollGreater() roll1 2}} {{#rollBetween() roll1 2 2}}&lt;div&gt;Roll Between 2 and 2&lt;/div&gt;{{/rollBetween() roll1 2 2}} &lt;h4&gt;Computed: {{computed::text}}/{{computed::roll1}}&lt;/h4&gt; {{#rollTotal() computed::roll1 2}}&lt;div&gt;Computed Roll Total 2&lt;/div&gt;{{/rollTotal() computed::roll1 2}} {{#rollLess() computed::roll1 3}}&lt;div&gt;Computed Roll Less 3&lt;/div&gt;{{/rollLess() computed::roll1 3}} {{#rollGreater() computed::roll1 1}}&lt;div&gt;Computed Roll Greater 1&lt;/div&gt;{{/rollGreater() computed::roll1 1}} {{#rollBetween() computed::roll1 2 2}}&lt;div&gt;Computed Roll Between 2 and 2&lt;/div&gt;{{/rollBetween() computed::roll1 2 2}} &lt;/rolltemplate&gt; &lt;script type="text/worker"&gt; on('clicked:test', (info) =&gt; { startRoll("&amp;{template:test} {{text=Text}} {{roll1=[[1d3]]}}", (results) =&gt; { console.log(results); finishRoll( results.rollId, { roll1: 2, text: "hi" } ); }); }); &lt;/script&gt; Expected output (focusing on computed): Computed: hi/<span class="userscript-inlinerollresult showtip tipsy-n-right fullcrit" title=" Rolling 1d3 = ( 3 )">2 Computed Roll Total 2 Computed Roll Less 3 Computed Roll Greater 1 Computed Roll Between 2 and 2 Actual output: Computed: /<span class="userscript-inlinerollresult showtip tipsy-n-right fullcrit" title=" Rolling 1d3 = ( 3 )">2 Computed Roll Less 3 Computed Roll Greater 1 Computed Roll Between 2 and 2 The computed text is missing and '{{#rollTotal() computed::roll1 2}}&lt;div&gt;Computed Roll Total 2&lt;/div&gt;{{/rollTotal() computed::roll1 2}}' is not triggering. Am I doing something wrong or are these bugs?
1629336106
Oosh
Sheet Author
API Scripter
You'll need to use an inline roll as a placeholder for your text. Replacing rolls only works with inline rolls. I'm not sure what's wrong with rollTotal... I do remember it wouldn't work the first time I tried it with computed rolls, but I can't remember what the issue was.
1629634810
Isurandil
Pro
Sheet Author
Oosh said: You'll need to use an inline roll as a placeholder for your text. Replacing rolls only works with inline rolls. This is not true, see the updated example: &lt;div&gt;&lt;button type="action" name="act_test"&gt;Click me&lt;/button&gt;&lt;/div&gt; &lt;rolltemplate class="sheet-rolltemplate-test"&gt; &lt;h4&gt;Uncomputed: {{text1}}/{{text2}}/{{roll1}}&lt;/h4&gt; {{#rollTotal() roll1 1}}&lt;div&gt;Roll Total 1&lt;/div&gt;{{/rollTotal() roll1 1}} {{#rollLess() roll1 2}}&lt;div&gt;Roll Less 2&lt;/div&gt;{{/rollLess() roll1 2}} {{#rollGreater() roll1 2}}&lt;div&gt;Roll Greater 2&lt;/div&gt;{{/rollGreater() roll1 2}} {{#rollBetween() roll1 2 2}}&lt;div&gt;Roll Between 2 and 2&lt;/div&gt;{{/rollBetween() roll1 2 2}} &lt;h4&gt;Computed: {{computed::text1}}/{{computed:text2}}/{{computed::roll1}}&lt;/h4&gt; {{#rollTotal() computed::roll1 2}}&lt;div&gt;Computed Roll Total 2&lt;/div&gt;{{/rollTotal() computed::roll1 2}} {{#rollLess() computed::roll1 3}}&lt;div&gt;Computed Roll Less 3&lt;/div&gt;{{/rollLess() computed::roll1 3}} {{#rollGreater() computed::roll1 1}}&lt;div&gt;Computed Roll Greater 1&lt;/div&gt;{{/rollGreater() computed::roll1 1}} {{#rollBetween() computed::roll1 2 2}}&lt;div&gt;Computed Roll Between 2 and 2&lt;/div&gt;{{/rollBetween() computed::roll1 2 2}} &lt;/rolltemplate&gt; &lt;script type="text/worker"&gt; on('clicked:test', (info) =&gt; { startRoll("&amp;{template:test} {{text1=Text}} {{text2=[[1d4]]}} {{roll1=[[1d3]]}}", (results) =&gt; { console.log(results); finishRoll( results.rollId, { roll1: 2, text1: "hi", text2: "o.O" } ); }); }); &lt;/script&gt; Computed output: Computed: // 2 Computed Roll Less 3 Computed Roll Greater 1 Computed Roll Between 2 and 2 Also, the documentation states: The function requires the rollId from the startRoll function, and can accept an object, where the keys are roll names and the values are the computed results for that roll, as a string or an integer. Obviously, you cannot use computed string results. Either the documentation is wrong or that's a Roll20 bug. Does anybody have an idea, why rollTotal does not trigger?
1629637456

Edited 1629637536
Oosh
Sheet Author
API Scripter
Text2 isn't working because you're missing a colon: computed:text2 text1 isn't working because {{text1=Text}} is not a roll, and as I said above, you can only replace rolls . The documentation you quoted clearly uses the word roll . The computed content doesn't have this limitation - it's about the initial template. I can show you multiple examples of inserting "computed" strings into a startRoll() if you'd like. Out of interest, does a NOT rollTotal work? I'm using those and haven't had any issues: {{#^rollTotal() computed::roll1 1}}&lt;div&gt;Computed result wasn't 1&lt;/div&gt;{{/^rollTotal() computed::roll1 1}}
1629644646

Edited 1629644704
Isurandil
Pro
Sheet Author
Oosh said: Text2 isn't working because you're missing a colon: computed:text2 text1 isn't working because {{text1=Text}} is not a roll, and as I said above, you can only replace rolls . The documentation you quoted clearly uses the word roll . The computed content doesn't have this limitation - it's about the initial template. I can show you multiple examples of inserting "computed" strings into a startRoll() if you'd like. Good catch, that was quite dumb! xD Now I can see that I misunderstood the documentation. Thank you very much :) At least, now I tried experimenting with strings and, unfortunately, I cannot inject (sanitized) HTML/CSS :( Oosh said: Out of interest, does a NOT rollTotal work? I'm using those and haven't had any issues: {{#^rollTotal() computed::roll1 1}}&lt;div&gt;Computed result wasn't 1&lt;/div&gt;{{/^rollTotal() computed::roll1 1}} Yep, that works: {{#^rollTotal() computed::roll1 3}}&lt;div&gt;Computed Roll Total Not 3&lt;/div&gt;{{/^rollTotal() computed::roll1 3}} Result: Computed Roll Total Not 3 So, at least one of the two (alleged) bugs I found seems to be a real one that needs fixing on Roll20's side. :D (BTW: {{#rollBetween() computed::roll1 2 2}} is functionally equivalent to {{#rollTotal() computed::roll1 2}}, so that works as workaround.)
1629675588
Oosh
Sheet Author
API Scripter
Ah yep, it still passes through the HTML filter. You can still get Roll20's [Link](buttons) to work, which means you can get limited inline styling and images in there - is that any help?
1629745784
Isurandil
Pro
Sheet Author
Oosh said: You can still get Roll20's [Link](buttons) to work, which means you can get limited inline styling and images in there - is that any help? Not sure what you mean, but I would have liked to use it to move some/all of the styling to the same JS parsing the roll and calculating the result - only one place to calculate and to react to rolls. Roll templates can be become a huge mess easily if you want to do slightly more advanced stuff. Nonetheless, with custom roll parsing, I have more than enough options to cut down on roll template sizes :)
1633266017
Isurandil
Pro
Sheet Author
Just for the record: After a little more than three weeks trying to reach someone at Roll20, I finally received a reply that (at least kind of) acknowledges the rollTotal() issue on 2021-09-14. Just to be sure, I asked again whether they are really looking at the right issue. I am still wondering why seemingly I am the only one experiencing this issue.
1633269139
GiGs
Pro
Sheet Author
API Scripter
It may be that startRoll isnt being widely used and tested yet.