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 .
×

Help with roll button.

I am working on a custom character sheet. Trying to make a roll button in a repeating section to roll a specific dice based on the selected character modified combat rating and the targets combat rating. This is what I have (which is not working): <!-- Skil repeating section --> <fieldset class="repeating_skills"> <!-- This checkbox acts as the trigger for the sheet worker --> <input type="checkbox" name="attr_roll_trigger" class="sheet-roll-trigger">     <!-- The button looks like a roll button but just toggles the checkbox --> <button type="roll" name="roll_combat_prompt" value="[[ ?{Enter Target|0} ]] @{temp_target_rating} @{roll_trigger}">Roll</button> <!-- Rest of fieldset --> <input type="text" name="attr_skill_name" placeholder="Skill Name"> <input type="number" name="attr_skill_level" placeholder="Lvl"> <input type="number" name="attr_skill_xp" placeholder="XP"> <input type="number" name="attr_skill_cost" placeholder="AP"> <input type="number" name="attr_skill_end" placeholder="EC"> <input type="text" name="attr_skill_info" placeholder="Skill Info"> </fieldset> // Sheet worker // // Combat Roll // on('change:repeating_skills:roll_trigger', (eventInfo) => {     // Get attributes for the specific row that triggered the change     getAttrs(['temp_target_rating', 'base_cr', 'repeating_skills_skill_name', 'repeating_skills_skill_level'], (values) => {         const target = parseFloat(values.temp_target_rating) || 0;         const base = parseFloat(values.base_cr) || 0;         const bonus = parseFloat(values.repeating_skills_skill_level) || 0;         const name = values.repeating_skills_skill_name || "Combat Check";                  const modified = base + bonus || 1;         const ratio = target / modified; console.log(ratio)         // Dice selection logic         let dice = "1d20";         if (ratio < 0.25) dice = "0";         else if (ratio < 0.5) dice = "1d4";         else if (ratio < 1) dice = "1d6";         else if (ratio < 2) dice = "1d8";         else if (ratio < 4) dice = "1d10";         else if (ratio < 8) dice = "1d12";         const rollString = `&{template:combat} {{name=${name}}} {{target=${target}}} {{modified=${modified}}} {{roll=[[${dice}]]}}`;                  startRoll(rollString, (results) => {             finishRoll(results.rollId, { roll: results.results.roll.result });                          // RESET the checkbox so it can be clicked again             setAttrs({ "repeating_skills_roll_trigger": "0" }, { silent: true });         });     }); }); //Roll template <rolltemplate class="sheet-rolltemplate-combat">     <div class="sheet-container">         <div class="sheet-header">{{name}}</div>         <div class="sheet-row">             <span>Target:</span> <span>{{target}}</span>         </div>         <div class="sheet-row">             <span>Modified Skill:</span> <span>{{modified}}</span>         </div>         <div class="sheet-row sheet-result">             <span>Result:</span> <span>{{computed::roll}}</span>         </div>     </div> </rolltemplate> When I press the button I get the prompt ok, but what gets displayed in Roll20 is:  9  0 on ( [[ ?{Enter Target|0} ]] @{Ukle|temp_target_rating} on)
1778429893
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
you are getting that output because that is what you have entered in the roll button. To trigger a sheetworker, you want to use an action button instead of the roll button/checkbox hack. <button type="action" name="act_roll-trigger">Roll</button> on('change:repeating_skills:roll-trigger', (eventInfo) => { Note that I changed the underscore to a dash. This is because action buttons in repeating sections will not fire their listener if they have an underscore in the actual button name.
Thanks Scott. So I made the changes:  <button type="action" name="act_roll-trigger" value="[[ ?{Enter Target|0} ]] @{temp_target_rating} @{roll-trigger}">Roll</button> but when I click the button , nothing happens (I did change the sheet-worker name to roll-trigger). No prompt and no roll.
1778433014
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
an action button doesn't use the value property at all. You'll need to do the query as part of your roll assembly
Thanks for the information. I got it sorted with that information.