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

Manipulating Roll Buttons in Fieldset Repeating Sections..

I am struggling a bit. I have a repeating section that for each row there is a roll button. Each roll button currently performs two rolls (checks).  I would like to remove the second check dependant on one of the values in the row. I would like to roll n d n + modifier   and if a certain "input select" (see image)  in the row is selected I would also like to roll a d12+modifier I would like to send the above to a template. I am familiar with workers and templates, including options for repeating section workers.  My first thought was to define a hidden attribute that would have a default value that would be changed if the selection value was changed. Then have the Roll Button just @the hidden attribute, the problem here is that the hidden field would also have @attribute references and im not sure if a nested parse for @attribs would work..  So im trying to control whether the d12 is actually rolled or not, and in the case where it isnt to not display it in the template. (Obviously an blank "" value for the 2nd check or its omission would allow me to withhold it from the template display. ) Included below: Code for the repeating section and its roll button. Included below: Image showing the selection field that determines whether a d12 is to also be rolled or not  <div class="div-actions"> <div class="div-top-band"> <h3>Attacks / Spells / Actions</h3> </div> <fieldset class="repeating_actions"> <div class="div-action-repeating"> <button type="roll" name="roll_action" class="input-action-roll" value="&{template:sorrowstale-action}{{check=[[@{action_numdice}@{action_die}+@{action_increment}]]}}{{checkd12=[[@1d12+@{action_d12bonus}]]}}{{charName=@{character_name}}}{{d12=@{action_d12}}}" > </button> <select name="attr_action_type" class="input-action-type"> <option selected>Attack</option> <option>Spell</option> <option>Action</option> <option>Effect</option> <option>Damage</option> <option>Other</option> </select> <input type="text" name="attr_action_desc" value="" class="input-action-desc" placeholder="Description"> <input type="number" name="attr_action_numdice" min="1" max="20" class="input-action-numdice nospinner" value="1" title = "# Dice" /> <input type="text" value="x" disabled class="input-action-labelx"> <select name="attr_action_die" class="input-action-die"> <option selected hidden readonly>Dice</option> <option>d20</option> <option>d12</option> <option>d10</option> <option>d8</option> <option>d6</option> <option>d4</option> <option>d100</option> </select> <input type="text" value="+" disabled class="input-action-labelx"> <input type="number" name="attr_action_increment" min="-30" max="30" class="input-action-increment nospinner" value="0" title = "Mod + Bonus" /> <select name="attr_action_d12" class="input-action-d12"> <option value="1" selected >☑ d12</option> <option value="2">☒ d12</option> </select> <input type="number" name="attr_action_d12bonus" min="-3" max="3" class="input-action-d12bonus nospinner" value="0" title = "d12 Bonus" /> <br /> </div> </fieldset> </div> Thanks Sorrow's Tale™
1656551710
Finderski
Pro
Sheet Author
Compendium Curator
So, one way of doing this would be to have the roll d12 option have the value of d12 and the option for not to roll a d12 have a value of 0, then just always include that attribute in the roll formula.
1656552951

Edited 1656553163
If i'm right in understanding what you are saying, having the value 1 and 0  for the selection and having that 1 or 0 used for n in n d12. This almost would work, save for the fact that im using an attribute to modify the d12 (action_d12bonus). Here is the check:   {{checkd12=[[@1d12+@{action_d12bonus}]]}} Please let me know if i'm misunderstanding.  EDIT: perhaps i can use 0 (or 1) * the actiond12bonus as well.... Thanks for the thought !
Okay the roll button now looks like this: <button type="roll" name="roll_action" class="input-action-roll" value="&{template:sorrowstale-action}{{check=[[@{action_numdice}@{action_die}+@{action_increment}]]}}{{checkd12=[[@{action_d12}d12+(@{action_d12}*@{action_d12bonus})]]}}{{charName=@{character_name}}}{{d12=@{action_d12}}}" > </button> Which does successfully conditionally remove the d12 roll. But unfortunately the template still displays a 2nd roll despite trying to counter it with the {{#rollGreater() d12 0}} As per the following template... <rolltemplate class="sheet-rolltemplate-sorrowstale-action"> <div class="sheet-container"> <div class="sheet-ability-roll"> <p style="line-height: 1.8;"> </p> {{#charName}}<span style="line-height: 2.3; font-size: 12px;">{{charName}} Rolls:</span>{{/charName}}<br /> {{#check}}<span>{{check}}</span><br />{{/check}} {{#rollGreater() d12 0}} <span>{{checkd12}}</span><br /> {{/rollGreater() d12 0}} {{#rollWasCrit() check}} <span>[ Critical Success ]</span>{{/rollWasCrit() check}} {{#rollWasFumble() check}}<span>[ Fail / Fumble ]</span>{{/rollWasFumble() check}} </div> <div class="sheet-ability-roll-footer"> {{#ability}}<span class="sheet-ability-font">{{ability}} </span>{{/ability}} {{#mod}}<span class="sheet-ability-font"> ({{mod}}) </span>{{/mod}} </div> </div> </rolltemplate> Any ideas? Thanks.
1656554928
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
So, it looks like your checkbox controls whether the d12 is rolled or not. What value are you using for the checked value of the checkbox?
1656575319

Edited 1656575496
GiGs
Pro
Sheet Author
API Scripter
By having the checkbox on your sheet, you force players to keep their sheet open when they roll the attack. One thing that is handy to be as a player is to create macros that launch buttons, which can then be made token actions or added to the macro bar. This lets players launch their favourite attacks or special abilities without opening their character sheet. If so, you wouldn't need the checkbox on the sheet, but include a query in the button value, asking if the extra die should be rolled. Would you prefer to do this? Also in your first post, your check12= value has this: [[@1d12+ Should that @ be there?
Hey Scott, If you would like to look at the code its at the top of the thread. The values used for this is 1 for do use d12 and 0 for don't, that way I can use it mathematically to include the d12 roll (1d12 vs 0d12). (I tried space for the dont roll d12 selection value, but that stopped the attribute option being saved on the character sheet (each time you opened the sheet the default selection displayed in this case). I was messing round with "" value so the template wouldn't show the check(roll). But as i mention this stopped the selection box selection from being saved.)
1656617011

Edited 1656617800
Hey GiGs, When an any attack is made in Sorrows Tale a d20 and a d12 is always rolled. The d20 determines if the attack physically hits the target and the d12 determines whether the armor is penetrated/defeated. As this type of roll is the most frequent in the game, I didn't want there to be a query each time, i wanted the players to set it up once on the given row. I see what you are saying about macros, i use this func as a player sometimes myself.  I'm nearly there, I just need to find a way of withholding the d12 check from the template display if it isn't selected.. I guess the template portion #rollGreater() isnt working as i expected it to or i have a syntax error in the close tag [there wasn't clarity re how to close two param helper functions in the documentation].  ( d12 has a value of 1 if d12 is selected and a value of 0 if don't roll d12 option is selected... ) {{#rollGreater() d12 0}} <span>{{checkd12}}</span><br /> {{/rollGreater() d12 0}} The repeating section has its own template (The whole template logic is posted in an earlier reply in this thread above), for now its not pretty like my other templates I will work on the aesthetics after i get the darn thing to work.. When the above button is pressed, it results in the second check (the d12 check) being displayed in error (as shown below)  i'm thinking because of the 0*0 modifier not the absent die roll. Any thoughts on how to achieve this in the template would be great!
1656618711
GiGs
Pro
Sheet Author
API Scripter
if the d12 is rolled every time, why is there a checkbox for it?
1656621087

Edited 1656621351
GiGs, Good question, every attack does, but there are other things that can go in repeating section that do not.. The repeating section is for the following roll types: Attack, Damage, Action, Spell, Effect and Other these non attack types mostly don't use a d12, spell and action are 50/50 for using d12, for example a charm spell doesn't need to defeat armor, but an acid jet spell needs to hit (d20) and defeat the corrode armor rating (d12) of the armor being worn.
1656635603

Edited 1656635792
Okay I have got it working.... Html Fragment <div class="div-actions"> <div class="div-top-band"> <h3>Attacks / Spells / Actions</h3> </div> <fieldset class="repeating_actions"> <div class="div-action-repeating"> <button type="roll" name="attr_action_roll" class="input-action-roll" value ="&{template:sorrowstale-action}{{charName=@{character_name}}}{{check=[[@{action_numdice}@{action_die}+@{action_increment}]]}}" > </button> <select name="attr_action_type" class="input-action-type"> <option selected>Attack</option> <option>Spell</option> <option>Action</option> <option>Effect</option> <option>Damage</option> <option>Other</option> </select> <input type="text" name="attr_action_desc" value="" class="input-action-desc" placeholder="Description"> <input type="number" name="attr_action_numdice" min="1" max="20" class="input-action-numdice nospinner" value="1" title = "# Dice" /> <input type="text" value="x" disabled class="input-action-labelx"> <select name="attr_action_die" class="input-action-die"> <option selected>d20</option> <option>d12</option> <option>d10</option> <option>d8</option> <option>d6</option> <option>d4</option> <option>d100</option> </select> <input type="text" value="+" disabled class="input-action-labelx"> <input type="number" name="attr_action_increment" min="-30" max="30" class="input-action-increment nospinner" value="0" title = "Mod + Bonus" /> <select name="attr_action_d12" class="input-action-d12"> <option value="1" selected >☑ d12</option> <option value="0">☒ d12</option> </select> <input type="number" name="attr_action_d12bonus" min="-3" max="3" class="input-action-d12bonus nospinner" value="0" title = "d12 Bonus" /> <br /> </div> </fieldset> </div> Sheet Worker Fragment on("change:repeating_actions:action_d12 change:repeating_actions:action_d12bonus", function() { getAttrs(["repeating_actions_action_d12", "repeating_actions_action_d12bonus"], function(values) { // the base template call and roll var setText = "&{template:sorrowstale-action}{{charName=@{character_name}}}{{check=[[@{action_numdice}@{action_die}+@{action_increment}]]}}"; // if boolean action_d12 = 1(true) then we add a d12 roll to setText if (values.repeating_actions_action_d12=="1") { setText = setText + "{{checkd12=[[1d12"; if (values.repeating_actions_action_d12bonus.trim()!="0") { setText = setText + "+@{action_d12bonus}"; } setText = setText + "]]}}"; } setAttrs({ repeating_actions_action_roll:setText}); }); });
1656636925

Edited 1656640372
GiGs
Pro
Sheet Author
API Scripter
You have a couple of inputs in there that don't have names: <input type="text" value="x" disabled class="input-action-labelx" <input type="text" value="+" disabled class="input-action-labelx"> Are they used? Also, since they don't contain calculations, using readonly is better than disabled . Note: if they are just there to have visible text on the sheet, using spans is better than inputs.
1656638111

Edited 1656638302
GiGs
Pro
Sheet Author
API Scripter
Also, a suggestion. Lines like this: < div class = "sheet-listspells__cell" >< input type = 'text' name = "attr_inventory1" value = "" /></ div >         < div class = "sheet-listspells__cell" >< input type = 'number' name = "attr_weight1" value = "0" /></ div > would be better written like this: < input type = 'text' name = "attr_inventory1" value = "" class = "sheet-listspells__cell" >         < input type = 'number' name = "attr_weight1" value = "0" class = "sheet-listspells__cell" > You can assign any style you give to the div directly to the input. And you probably don't need the class on thos inputs either, and can do with: < div class = "sheet-listspells__row" > < input type = 'text' name = "attr_inventory1" value = "" >         < input type = 'number' name = "attr_weight1" value = "0" > And in your CSS, have something like div. sheet-listspells__row > input[type=text] { That will assign the CSS to all text type inputs directly inside and divs with the sheet-listspells__row class. or for all inputs div. sheet-listspells__row > input { Note that on roll20, number inputs have a bunch of styles, so you need substantial specificity to overcome them, something like .charsheet div. sheet-listspells__row > input[type=number], .charsheet div. sheet-listspells__row > input[type=text] { will do it I think (from memory).
You have a couple of inputs in there that don't have names: <input type="text" value="x" disabled class="input-action-labelx" <input type="text" value="+" disabled class="input-action-labelx"> Are they used? Also, since they don't contain calculations, using  readonly  is better than  disabled . Note: if they are just there to have visible text on the sheet, using spans is better than inputs. Yes they started off in life being used differently, now they are better off as Spans -- I have yet to refactor the code.  < div class = "sheet-listspells__cell" >< input type = 'text' name = "attr_inventory1" value = "" /></ div >         < div class = "sheet-listspells__cell" >< input type = 'number' name = "attr_weight1" value = "0" /></ div > would be better written like this: < input type = 'text' name = "attr_inventory1" value = "" class = "sheet-listspells__cell" >         < input type = 'number' name = "attr_weight1" value = "0" class = "sheet-listspells__cell" > I'm not sure where you are seeing tight individually div wrapped inputs. My div classes  tend to set the background and flow etc for the div. I use element classes where required for the elements in the div..  GiGs thanks as always for your inputs.
1656711343

Edited 1656711394
GiGs
Pro
Sheet Author
API Scripter
Sorrow's Tale™ said: < div class = "sheet-listspells__cell" >< input type = 'text' name = "attr_inventory1" value = "" /></ div >         < div class = "sheet-listspells__cell" >< input type = 'number' name = "attr_weight1" value = "0" /></ div > would be better written like this: < input type = 'text' name = "attr_inventory1" value = "" class = "sheet-listspells__cell" >         < input type = 'number' name = "attr_weight1" value = "0" class = "sheet-listspells__cell" > I'm not sure where you are seeing tight individually div wrapped inputs. My div classes  tend to set the background and flow etc for the div. I use element classes where required for the elements in the div..  GiGs thanks as always for your inputs. I'm not seeing them now either. Maybe I somehow copied them from a different thread! Edit: I think that's exactly what happened. I think i know the thread. Oops.