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

Sheet Author Guide: Rolltemplates

August 09 (1 year ago)

Edited July 14 (8 months ago)
GiGs
Pro
Sheet Author
API Scripter

As some of you know, I'm creating a sheet author guide. I went a bit overboard of repeating sections, but I'm winding down my 25-part series there: https://cybersphere.me/roll20-sheet-author-master-list/. (also https://cybersphere.me/roll20/)

I'm planning to write about rolltemplates next and thought I'd ask you what I should include. You were really helpful last time.

This should answer people's questions and confusion about adding a rolltemplate to a character sheet. What should I include? Hopefully it'll be a lot shorter than last time!

Ignore translations for now - I'll be covering them later. Also custom roll parsing can be used to simplify rolltemplates-  but I won't be covering them here.

Some things I'll definitely be including:

  • How rolltemplates still need legacy code, and how you need to create a container to include the output
  • Logic helpers (possibly lots to write here, including the role of inline rolls)
  • The fact you cant perform calculations in a rolltemplate (but you can in the macro you send to the template).
  • The way reusing rolls output can be used in rolltemplates

What do you think I should cover? What has caused you confusion, or do you have to kick yourself to remember each time?

August 09 (1 year ago)
vÍnce
Pro
Sheet Author

Great series GiGs.
- might mention how 3d dice results often do not match rolls made within roll templates since 3d dice show the dice for all rolls included in the macro regardless of roll template logic used to hide/show elements/results.

- styling chat menu buttons and/or links using the roll template.

- darkmode styling

- using allprops to handle any "undefined/custom" roll template keys

Hard to decide what to include since the wiki does have lots info about roll templates.

August 10 (1 year ago)

Edited August 10 (1 year ago)
GiGs
Pro
Sheet Author
API Scripter

Those are good suggestions - I might not have considered 3d dice at all.

Yes, there's a lot on the wiki. My goal isn't to replace that, or even necessarily include everything it includes (when I talked about CSE I was conscious of not mentioning everything that could be found on the wiki). My goal is to present things in a different way, in more digestible chunks and hopefully easier to learn, and leave readers ebtter prepared to find the extra stuff they need.

August 16 (1 year ago)
Peter B.
Plus
Sheet Author

I would including the following:

  • Case sensitivity, i.e. {{name=Tobi}} vs {{Name=Tobi}} is not the same
  • Careful with leading whitespaces, i.e. {{name=Tobi}} vs {{ name = Tobi}}
  • The handling of newline for templates. A simple way that always work to make a newline is to use %NEWLINE%, but if you have a HTML textarea as the source for the template you can simply make a newline in the textarea field and it will work
  • Styling of random text: Using *italic*, **bold**, ***italic and bold***
  • Indention: Using   or   to indent a larger piece of text
  • Finally be careful to to add newlines between properties, i.e.:

This works

&{template:2Edefault} {{name=Sir Brian}} {{desc=You take a lot of damage and
DIE!}}

This does not work

&{template:2Edefault}
{{name=Sir Brian}}
{{desc=You take a lot of damage and DIE!}}
August 16 (1 year ago)
GiGs
Pro
Sheet Author
API Scripter

Thats a good list. I had considered the sheet author side, but not the rolltemplate writer side (for when people create their own macros and abilities).

August 16 (1 year ago)

Edited August 16 (1 year ago)
vÍnce
Pro
Sheet Author

Maybe include something about using keys as "flags" in your roll templates to toggle hiding/showing elements.  This can be especially handy when an author uses only one roll template for a sheet.

August 16 (1 year ago)
GiGs
Pro
Sheet Author
API Scripter

Are you referring to the way you can do {{#key}}some stuff only shown when that key is present{{/key}} ?

August 16 (1 year ago)

Edited August 16 (1 year ago)
vÍnce
Pro
Sheet Author

Yes.  More specifically something like {{#keyflag}} {{keyflag}} {{/keyflag}}
In the macro you would include {{keyflag=@{keyflag}}}
Where the HTML for @{keyflag} would either be empty or a value.  If empty/null, nothing would be shown according to the template handling.
These types of attrib could be set using a selector or better yet, a sheetworker.

Could be used for whisper toggling or other player-sheet options like color, font, crit handling, etc.
August 17 (1 year ago)

Edited August 17 (1 year ago)
GiGs
Pro
Sheet Author
API Scripter

I'm not sure I'm folowing you fully there. Yes, you can do {{#key}}{{key}}{{/key}} so if you have something like {{key=Show me!}} in the rolltemplate it will be shown in the output.

If it doesnt exist, it wont be shown. Are you saying it will not be shown if its empty, like {{key=}} ? I haven't tested that, but I need to.


There's a couple of other things you said that raise questions;

"These types of attrib could be set using a selector or better yet, a sheetworker." - can you explain what you mean here?

"Could be used for whisper toggling or other player-sheet options like color, font, crit handling, etc." I'm not sure what you're describing here? With a rolltemplate you can't set the value of anything. You can only read existing values. Am I missing something?

August 17 (1 year ago)
GiGs
Pro
Sheet Author
API Scripter


GiGs said:

If it doesnt exist, it wont be shown. Are you saying it will not be shown if its empty, like {{key=}} ? I haven't tested that, but I need to.

Quick test - empty keys {{key=}} do get displayed - they don't get ignored. There's just nothing to show.

August 17 (1 year ago)

Edited August 17 (1 year ago)
vÍnce
Pro
Sheet Author
Sorry for being vague. The template cannot set values but you can use it to hide/show rolltemplate sections to chat.

Probably better if I just post an example.
Here's a striped down version of something I've used on the Forbidden Lands Sheet
HTML
<input type="hidden" name="attr_include_with_roll" value="" readonly />
<rolltemplate class="sheet-rolltemplate-forbiddenlands">
  <div class="template-wrap">
    <div class="template-grid">
      {{#pride-flag}}
        <div class="template-grid-item template-span-six pride-flag"></div>
      {{/pride-flag}}
    </div>
   </div>
   {{#allprops() pride-flag}}
    <div class="template-grid-item template-span-half">
     <span>**{{key}}**:</span>
     </div>
     <div class="template-grid-item template-span-2nd-half">
     <span>{{value}}</span>
     </div>
   {{/allprops() pride-flag}}
</rolltemplate>

I use a sheetworker to set @{include_with_roll} when the Reputation Roll action button is pressed.
ie
  on('clicked:reputation-roll', function (eventInfo) {    
setAttrs({
include_with_roll: '{{dice-label-flag=1}}',
});
});

I include @{include_with_roll} with all the sheet rolls. It gets modified depending on which button is pressed.
So, normally <div class="template-grid-item template-span-six pride-flag"></div> from the template is never included with template for other rolls, but if the Pride roll is made, the roll gets formatted appropriately.
August 17 (1 year ago)
GiGs
Pro
Sheet Author
API Scripter

Is that a rolltemplate tip, or a general sheet worker and CSS trick?

August 17 (1 year ago)
vÍnce
Pro
Sheet Author


GiGs said:

Is that a rolltemplate tip, or a general sheet worker and CSS trick?

Probably more than just a roll template template tip. ;-)  Kind of combines everything I guess.


August 17 (1 year ago)

Edited August 17 (1 year ago)
GiGs
Pro
Sheet Author
API Scripter

The way I've set about creating the guide does have trouble with tips that cross multiple categories. I have one section for each of HTML, CSS, Javascript/Sheet workers, Repeating Sections, and soon rolltemplates and Custom Roll Parsing. But tips that aren't really about those things don't really have anywhere to fit. I'll have to think about that.

August 18 (1 year ago)
GiGs
Pro
Sheet Author
API Scripter


Peter B. said:

  • The handling of newline for templates. A simple way that always work to make a newline is to use %NEWLINE%, but if you have a HTML textarea as the source for the template you can simply make a newline in the textarea field and it will work

I just realised I don't understand something you said here. rolltemplates use the rolltemplate element, so I'm not sure what you mean when you refer to a textarea here. Can you explain that comment?