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

1691611877

Edited 1720987466
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: <a href="https://cybersphere.me/roll20-sheet-author-master-list/" rel="nofollow">https://cybersphere.me/roll20-sheet-author-master-list/</a>. (also <a href="https://cybersphere.me/roll20/" rel="nofollow">https://cybersphere.me/roll20/</a> ) 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-&nbsp; 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?
1691624866
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.
1691625870

Edited 1691632773
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.
1692164215
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 &nbsp; *italic*,&nbsp; **bold** , ***italic and bold*** Indention: Using &amp;emsp; or &amp;ensp; to indent a larger piece of text Finally be careful to to add newlines between properties, i.e.: This works &amp;{template:2Edefault} {{name=Sir Brian}} {{desc=You take a lot of damage and DIE!}} This does not work &amp;{template:2Edefault} {{name=Sir Brian}} {{desc=You take a lot of damage and DIE!}}
1692190354
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).
1692199553

Edited 1692199564
vÍnce
Pro
Sheet Author
Maybe include something about using keys as "flags" in your roll templates to toggle hiding/showing elements.&nbsp; This can be especially handy when an author uses only one roll template for a sheet.
1692210070
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}} ?
1692214607

Edited 1692215528
vÍnce
Pro
Sheet Author
Yes.&nbsp; 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.&nbsp; 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.
1692232409

Edited 1692236598
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?
1692232828
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.
1692241740

Edited 1692242009
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 &lt;input type="hidden" name="attr_include_with_roll" value="" readonly /&gt; &lt;rolltemplate class="sheet-rolltemplate-forbiddenlands"&gt; &nbsp; &lt;div class="template-wrap"&gt; &nbsp;&nbsp;&nbsp; &lt;div class="template-grid"&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {{#pride-flag}} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;div class="template-grid-item template-span-six pride-flag"&gt;&lt;/div&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {{/pride-flag}} &nbsp;&nbsp;&nbsp; &lt;/div&gt; &nbsp;&nbsp; &lt;/div&gt; &nbsp;&nbsp;&nbsp;{{#allprops() pride-flag}} &nbsp;&nbsp;&nbsp; &lt;div class="template-grid-item template-span-half"&gt; &nbsp;&nbsp;&nbsp;&nbsp; &lt;span&gt;**{{key}}**:&lt;/span&gt; &nbsp;&nbsp;&nbsp;&nbsp; &lt;/div&gt; &nbsp;&nbsp;&nbsp;&nbsp; &lt;div class="template-grid-item template-span-2nd-half"&gt; &nbsp;&nbsp;&nbsp;&nbsp; &lt;span&gt;{{value}}&lt;/span&gt; &nbsp;&nbsp;&nbsp;&nbsp; &lt;/div&gt; &nbsp;&nbsp;&nbsp;{{/allprops() pride-flag}} &lt;/rolltemplate&gt; 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 &lt;div class="template-grid-item template-span-six pride-flag"&gt;&lt;/div&gt; from the template is never included with template for other rolls, but if the Pride roll is made, the roll gets formatted appropriately.
1692242243
GiGs
Pro
Sheet Author
API Scripter
Is that a rolltemplate tip, or a general sheet worker and CSS trick?
1692242461
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. ;-)&nbsp; Kind of combines everything I guess.
1692284864

Edited 1692284891
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.
1692394377
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?