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

how to create use the product of a rolltemplate in the rolltemplate call?

1728149412

Edited 1728149424
GiGs
Pro
Sheet Author
API Scripter
Is it possible to style part of a rolltemplate with something generated in that template? All the templates I've seen have a fixed value (like, say, {{colour=green}}). Using custom roll parsing, it's possible to generate a roll but is there any way to add that back into a rolltemplate in the format you can actually use in a rolltemplate? I want to create a CSS class (or any method that works) with the product of a roll. I have a roll that generates a label "Superb", and using custom roll parsing, this is the product of {{computed::total}} . In naiively thought I'd be able to do class=" sheet- {{computed::total}}" but that generates : class="span class="inlinerollresult showtip tipsy-n-right fullfail" original-title="<img src="/images/quantumrollwhite.png" class="inlineqroll"> Rolling 1d6-1d6 + 0[Compel]  + 0[Rank] + 0[Modifier] + 0[Power] = (<span class="basicdiceroll">4</span>)-(<span class="basicdiceroll critfail ">1</span>)+0+0+0+0">Superb</span>" That is not what I want!
1728239660
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Unfortunately, computed is still an inline roll. The trick of template fields in the class declaration only works if the field is just text. Only way to get the end result you want is good old roll template logic and helper functions with the various display modes specified in the template.
1728243492

Edited 1728246294
GiGs
Pro
Sheet Author
API Scripter
Scott C. said: Unfortunately, computed is still an inline roll. The trick of template fields in the class declaration only works if the field is just text. Only way to get the end result you want is good old roll template logic and helper functions with the various display modes specified in the template. After posting, I did think of a potential way. Have two rolls: the first roll generates the results but starts with ! so it is not visible, and uses setAttrs to save th resultd. The second roll is nested within the first, doesn't use !, and grabs the value you want using getAttrs. That sounds very convoluted - would it work?
1728244085
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
it'd work, but the question is whether it's better than just using the template to conditionally create the content.
1728246395
GiGs
Pro
Sheet Author
API Scripter
Scott C. said: it'd work, but the question is whether it's better than just using the template to conditionally create the content. I think I'm missing something. Are you referring to the use of logic helpers you alluded to earlier?
1728254776
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Yes, something like: {{#rollTotal() computed::superb 1}} <!-- Content for when superb --> {{/rollTotal() computed::superb 1}} {{#^rollTotal() computed::superb 1}} <!-- Content for when not superb --> {{/^rollTotal() computed::superb 1}}
1728362769
GiGs
Pro
Sheet Author
API Scripter
That is a great idea. Thanks for the suggestion! It took me a long time to respond because i thought I might have hit a bug. Instead, I'd been caught out by some recent behaviour of VS Studio that I'm finding very irritating. When you copy HTML code (like, say <div>), and it detects that code has a closure (like </div>) it automatically adds it to the copied text - but that probably already exists elsewhere in the code. I have been caught out by this so many times in the last week or so, at least I'm starting to look for it now.
1728625721
Mago
Sheet Author
i did something similar in a template, hiding certain messages with a different font color, using helper functions to reveal the fields, in case of a critical or a fumble or a roll total I also figured that you could have template fields that are hidden by the allprops helper, and then reference them in a different part of the template, this has helped me hide dice rolls that are later shown elsewhere