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

Roll Template Tomfoolery (repost from Pro)

Hi All, This is my first go at making a roll template for a custom sheet and I could use some help. This is what I'm using to roll a d666. The first two dice are to be matched against a target value, the last is there for degree of success/failure: <button name="roll_action" type="roll" value="&{template:default} {{Attribute Roll vs ?{Target}=[[2d6]]}} {{Check Digit=[[1d6]]}}"></button> I'd like to make a roll template that does the following. First two points are priority, last two are nice to have. No crit colours on the dice. If the 2d6 roll is less than or equal to the target, there should be a green outline around the whole thing, red if otherwise. if all the dice come up 1, a yellow outline and "Divine Intervention" as the header if all the dice come up 6, a black outline and "Demonic Intervention" as the header Any advice or even directions to stuff I can copy/adapt would be helpful.
1645803527
Andreas J.
Forum Champion
Sheet Author
Translator
Sounds like something to be implemented with: <a href="https://wiki.roll20.net/Custom_Roll_Parsing" rel="nofollow">https://wiki.roll20.net/Custom_Roll_Parsing</a>
1645807054
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Yep, Andreas has the right of it. This will be a combination of CRP, roll template helper functions, and CSS. It'd be something like this: HTML/JS &lt;button type="action" name="act_roll"&gt;Roll check&lt;/button&gt; &lt;rolltemplate class="sheet-rolltemplate-my-template"&gt; &lt;div class="template-container"&gt; {{#rollGreater() computed::intervention 0}} &lt;span class="divine" data-i18n="divine intervention"&gt;&lt;/span&gt; {{/rollGreater() computed::intervention 0}} {{#rollLess() computed::intervention 0}} &lt;span class="demonic" data-i18n="demonic intervention"&gt;&lt;/span&gt; {{/rollLess() computed::intervention 0}} &lt;div class="template-row"&gt; &lt;span class="row-head" data-i18n="target"&gt;&lt;/span&gt; &lt;span class="result"&gt;{{target}}&lt;/span&gt; &lt;/div&gt; &lt;div class="template-row"&gt; &lt;span class="row-head" data-i18n="roll"&gt;&lt;/span&gt; {{#rollGreater() computed::vs 0}} &lt;span hidden class="success"&gt;&lt;/span&gt; {{/rollGreater() computed::vs 0}} &lt;span class="result"&gt;{{roll}}&lt;/span&gt; &lt;/div&gt; &lt;div class="template-row"&gt; &lt;span class="row-head" data-i18n="check digit"&gt;&lt;/span&gt; &lt;span class="result"&gt;{{check}}&lt;/span&gt; &lt;/div&gt; &lt;/div&gt; &lt;/rolltemplate&gt; &lt;script type="text/worker"&gt; const initiateRoll = async function(event){ //I'm not going to use the event object here, but you can use it to have this function dynamically foll whatever is needed (within reason) based on the triggerName property. let rollText = `&amp;{template:my-template} {{intervention=[[0[computed value]]]}} {{target=[[?{What's your target number|12}]]}} {{roll=[[2d6]]}} {{check=[[1d6]]}} {{vs=[[0[computed value]]]}}`; const rollResult = await startRoll(rollText); const computeObj = {};//An object to store the computation changes to the roll displays. const rollDice = rollResult.results.roll.dice; const checkDice = rollResult.results.check.dice; const allDice = [...rollDice,...checkDice]; //The below ternary will set intervention to 1 if all dice are 1's, or -1 if all dice are 6's. If neither of these is true, then it sets it to 0. computeObj.intervention = allDice.every((die)=&gt;die===1) ? 1 : allDice.every((die)=&gt;die===6) ? -1 : 0; computeObj.vs = rollResult.results.roll.result &lt;= rollResult.results.target.result ? 1 : 0; finishRoll(rollResult.rollId,computeObj);//Release the roll to chat and apply our computation changes. } on('clicked:roll',initiateRoll); &lt;/script&gt; CSS .sheet-rolltemplate-my-template .inlinerollresult, .sheet-rolltemplate-my-template .inlinerollresult.fullcrit, .sheet-rolltemplate-my-template .inlinerollresult.fullfail, .sheet-rolltemplate-my-template .inlinerollresult.importantroll { border-color: transparent; background-color:transparent; } .sheet-rolltemplate-my-template .sheet-success + .sheet-result .inlinerollresult{ border-color:green; } .sheet-rolltemplate-my-template .sheet-demonic ~ .sheet-template-row .inlinerollresult{ border-color:black; } .sheet-rolltemplate-my-template .sheet-divine ~ .sheet-template-row .sheet-result .inlinerollresult{ border-color:yellow; } I've made the intervention coloring pretty broad here for demo purposes, but you can limit it if that's what you need by adding a class to the template-rows that you do want it to be colored in and then adding that class to the color css declarations for the two intervention states. You might also be interested in the Sheet Creation tutorial series that I'm currently doing, A Sheet Author's Journey . Hope that helps. -Scott
1646223824

Edited 1646225584
Thanks so much Scott! I'll have a look at this. Thanks for getting me started! Scott C. said: Yep, Andreas has the right of it. This will be a combination of CRP, roll template helper functions, and CSS. It'd be something like this: HTML/JS &lt;button type="action" name="act_roll"&gt;Roll check&lt;/button&gt; &lt;rolltemplate class="sheet-rolltemplate-my-template"&gt; &lt;div class="template-container"&gt; {{#rollGreater() computed::intervention 0}} &lt;span class="divine" data-i18n="divine intervention"&gt;&lt;/span&gt; {{/rollGreater() computed::intervention 0}} {{#rollLess() computed::intervention 0}} &lt;span class="demonic" data-i18n="demonic intervention"&gt;&lt;/span&gt; {{/rollLess() computed::intervention 0}} &lt;div class="template-row"&gt; &lt;span class="row-head" data-i18n="target"&gt;&lt;/span&gt; &lt;span class="result"&gt;{{target}}&lt;/span&gt; &lt;/div&gt; &lt;div class="template-row"&gt; &lt;span class="row-head" data-i18n="roll"&gt;&lt;/span&gt; {{#rollGreater() computed::vs 0}} &lt;span hidden class="success"&gt;&lt;/span&gt; {{/rollGreater() computed::vs 0}} &lt;span class="result"&gt;{{roll}}&lt;/span&gt; &lt;/div&gt; &lt;div class="template-row"&gt; &lt;span class="row-head" data-i18n="check digit"&gt;&lt;/span&gt; &lt;span class="result"&gt;{{check}}&lt;/span&gt; &lt;/div&gt; &lt;/div&gt; &lt;/rolltemplate&gt; &lt;script type="text/worker"&gt; const initiateRoll = async function(event){ //I'm not going to use the event object here, but you can use it to have this function dynamically foll whatever is needed (within reason) based on the triggerName property. let rollText = `&amp;{template:my-template} {{intervention=[[0[computed value]]]}} {{target=[[?{What's your target number|12}]]}} {{roll=[[2d6]]}} {{check=[[1d6]]}} {{vs=[[0[computed value]]]}}`; const rollResult = await startRoll(rollText); const computeObj = {};//An object to store the computation changes to the roll displays. const rollDice = rollResult.results.roll.dice; const checkDice = rollResult.results.check.dice; const allDice = [...rollDice,...checkDice]; //The below ternary will set intervention to 1 if all dice are 1's, or -1 if all dice are 6's. If neither of these is true, then it sets it to 0. computeObj.intervention = allDice.every((die)=&gt;die===1) ? 1 : allDice.every((die)=&gt;die===6) ? -1 : 0; computeObj.vs = rollResult.results.roll.result &lt;= rollResult.results.target.result ? 1 : 0; finishRoll(rollResult.rollId,computeObj);//Release the roll to chat and apply our computation changes. } on('clicked:roll',initiateRoll); &lt;/script&gt; CSS .sheet-rolltemplate-my-template .inlinerollresult, .sheet-rolltemplate-my-template .inlinerollresult.fullcrit, .sheet-rolltemplate-my-template .inlinerollresult.fullfail, .sheet-rolltemplate-my-template .inlinerollresult.importantroll { border-color: transparent; background-color:transparent; } .sheet-rolltemplate-my-template .sheet-success + .sheet-result .inlinerollresult{ border-color:green; } .sheet-rolltemplate-my-template .sheet-demonic ~ .sheet-template-row .inlinerollresult{ border-color:black; } .sheet-rolltemplate-my-template .sheet-divine ~ .sheet-template-row .sheet-result .inlinerollresult{ border-color:yellow; } I've made the intervention coloring pretty broad here for demo purposes, but you can limit it if that's what you need by adding a class to the template-rows that you do want it to be colored in and then adding that class to the color css declarations for the two intervention states. You might also be interested in the Sheet Creation tutorial series that I'm currently doing, A Sheet Author's Journey . Hope that helps. -Scott