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?

October 05 (5 months ago)

Edited October 05 (5 months ago)
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=&quot;/images/quantumrollwhite.png&quot; class=&quot;inlineqroll&quot;> Rolling 1d6-1d6 + 0[Compel]  + 0[Rank] + 0[Modifier] + 0[Power] = (<span class=&quot;basicdiceroll&quot;>4</span>)-(<span class=&quot;basicdiceroll critfail &quot;>1</span>)+0+0+0+0">Superb</span>"

That is not what I want!

October 06 (5 months ago)
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.

October 06 (5 months ago)

Edited October 06 (5 months ago)
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?

October 06 (5 months ago)
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.

October 06 (5 months ago)
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?

October 06 (5 months ago)
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}}

October 08 (5 months ago)
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.

October 11 (5 months ago)
Mago
Pro
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