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 Workers] GetAttrs & Repeating Sections

This doesn't seem to work for whatever reason when I have tried this. This is straight from the wiki on the getAttrs() function: If the event that you are inside of is already inside of a repeating section, you can simply request the variable using its name prefaced by the repeating group name and you will receive the value in the same repeating section the event was triggered in.   on("change:repeating_spells:spelllevel", function() { getAttrs([ "repeating_spells_SpellDamage", "repeating_spells_SpellName" ], function(values) { //values.repeating_spells_SpellDamage and values.repeating_spells_SpellName //will both be from the same repeating section row that the SpellLevel that changed is in. }); }); I've tried this in my own repeating sections and it has never worked. For example, I have a repeating section for an item. Inside that item it has a name, tags, damage, armor, weight, and value. I detect the change event like above on the repeating section and then using getAttrs I should be able to reference any other attribute in the row using getAttrs right? That doesn't seem to be the case.. am I missing something here? Is there an ${id} for the repeating row that needs to be thrown in there for the getAttrs call?  Thank you for any help provided. 
1516606247
Jakob
Sheet Author
API Scripter
This should work, as long as the event comes from within the repeating section. Can you provide an example of code that should work, but doesn't? You should only need to use the id(s) when the event is triggered outside the repeating section.
Hi Jakob,  I just realized where I went wrong.. I was omitting the "repeating_section_" in my call to the values object. DOH! *slaps forehead*  I added that to the below code and it returned values without issue. Thanks for your help! Here's an example of the code I was using..  <!-- ===== SHIELD ===== --> <div class="sheet-header"> <div class="sheet-section-name">Equipped Shield</div> </div> <div class="sheet-section-shield">     <fieldset class="repeating_shields">     <input name="attr_item_name" type="text" placeholder="Name" />             <input type="checkbox" class="sheet-toggle" title="show/hide" name="attr_shield_show" value="1" />     <div class="sheet-hide">         <input name="attr_item_tags" type="text" placeholder="Tags" />                 <div class="sheet-clearfix"></div>     Armor Rating:         <select name="attr_item_armor">                                     <option value="0">0</option>                     <option value="1">1</option>                     <option value="2">2</option>                     <option value="3">3</option>                     <option value="4">4</option>                     <option value="5">5</option>                     <option value="6">6</option>                     <option value="7">7</option>                     <option value="8">8</option>                     <option value="9">9</option>                 </select>                 Weight:         <select name="attr_item_weight">                                     <option value="0">0</option>                     <option value="1">1</option>                     <option value="2">2</option>                     <option value="3">3</option>                     <option value="4">4</option>                     <option value="5">5</option>                     <option value="6">6</option>                     <option value="7">7</option>                     <option value="8">8</option>                     <option value="9">9</option>                 </select>                 <div class="sheet-clearfix"></div>                 Value:                  <input name="attr_itemvalue" type="number" min="0" value="0"/>                 <div class="sheet-clearfix"></div>                 <input type="checkbox" name="attr_shield_damaged" value="1">Damaged</input>                 <div class="sheet-clearfix"></div>             </div>             <input type="checkbox" name="attr_shield_equipped" value="1">Equipped</input>         </fieldset>     </div> --SHEET WORKER SECTION-- //SHIELD CHANGE EVENT HANDLER //Calculates the total armor rating with the shield equipped by the character //on("change:repeating_shields", function() { on("change:repeating_shields:item_armor change:repeating_shields:shield_equipped", function() {    getAttrs([       "repeating_shields_item_armor",       "repeating_shields_shield_equipped"     ], function(values) {         var equipValue;         var armorValue;         var totalArmorRating = 0;                  console.log(values.repeating_shields_item_armor);         console.log(values.repeating_shields_shield_equipped);                          armorValue = Number(values.repeating_shields_item_armor);         equipValue = Number(values.repeating_shields_shield_equipped);                                          if (equipValue == 1) {             totalArmorRating = totalArmorRating + Number(armorValue);         }                              setAttrs({             calc_shield_armor_total: totalArmorRating         });    }); });