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

Getting Values out of [Repeating Section]

Alright this is day two of my working on this sheet and I am still stuck on how to retrieve my values from repeating sections. This seems like something that should be easily done. I need it to function like this: -Players can add repeating section of Skills with a {dicevalue}d4-12, repeating section of Abilities {dicevalue}d4-12. -Players then use a checkbox to select 1 Skill and 1 Ability. -The roll button at the top of the sheet takes the {dicevalue} of the selected Skill and the {dicevalue} of the selected Ability and puts them into a die roll code.  Ability Dice Dexterity 1d10 [  ] Charisma 1d12 [  ] I have something like this as a repeating section: Skills Dice Stealth 1d6 [  ] Bluff 1d8 [  ] Then another repeating section. I need to be able to check off the box [  ] for a Skill and an Ability, and have the {dice} value brought out of the repeating section and into the roll button at the top of the page. I am definitely missing something I understand about the lexical scope of programming but not with HTML! It's definitely on the end of what Roll20 does with the information, which I am not very familiar with. 
1518766760

Edited 1518767020
GiGs
Pro
Sheet Author
API Scripter
The only way I know to do what you're asking is with a sheetworker, and manipulating repeating sets with sheet workers is pretty tricky. Here's a quick and dirty approach. Assuming you have a repeating set defined like this: <h3>Qualities</h3>     <fieldset class="repeating_skills">         <input type="text" name="attr_skill" style="width: 70%; float: left;">         <select name="attr_skilldtype" style="width: 20%; float: left;">         <option value="d0" selected>-</option>         <option value="d4">d4</option>         <option value="d6">d6</option>         <option value="d8">d8</option>         <option value="d10">d10</option>         <option value="d12">d12</option>         </select>         <input type="checkbox" name="attr_skillcheck" value="1">     </fieldset> And also outside of the set: <input type="text" name="attr_skill_chosen" > <input type="text" name="attr_skill_value" > The following sheetworker will update the skill_chosen and skill_value whenever you click the checkbox.  It will also immediately uncheck the checkbox, because keeping track of which checkbox is checked is one of trickiest elements of repeating set coding, and this is a quick-and-dirty solution. <script type="text/worker"> on("change:repeating_skills:skillcheck", function(eventInfo) {    getAttrs(["repeating_skills_skill","repeating_skills_skilldtype","repeating_skills_skillcheck"],function(v) {        let check = parseInt(v.repeating_skills_skillcheck)||0;         if(check === 1) {             let skill = v.repeating_skills_skill;             let value = v.repeating_skills_skilldtype;             setAttrs({                 "skill_chosen": skill,                 "skill_value": value,           "repeating_skills_skillcheck":0         });              }    }); }); // all other sheet workers go here, before the /script. </script> Note: all sheet workers must be placed inside the same script tag. You can duplicate this sheetworker for your other repeating set, changing all "skills" and "skill" to the other sets name. Assuming that other set is named repeating_ability, you need a button to roll, which will look something like this: <button type="roll" value="**@{skill_chosen} + @{ability_chosen}** Check:[[ @{skill_value}+@{ability_value} ]]" ></button> or simply <button type="roll" value="/roll @{skill_value}+@{ability_value}" ></button>
That is super helpful! I can see now how everything under the hood works at least. I will try and get all of that working for my v2 of the sheet. 
1518855142
GiGs
Pro
Sheet Author
API Scripter
There are some syntax things to watch out for with repeating sets and sheet workers, for instance on("change:repeating_skills:skillcheck", function(eventInfo) {    getAttrs(["repeating_skills_skill", Note the colon on the events line (change, etc) line, replaced by an underscore on the getAttributes line. The first line, the events line, also always needs things to be in lower case, so if you were triggering a sheetworker when the stat "DEX" changed, the first two lines would probably look like this: on("change:dex", function() {    getAttrs(["DEX"],function(v) { That's a very common point of confusion, so I thought I'd mention it.