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

Repeatable formulas within a Repeatable field - how do you do them?

1474582792
Falcon
Pro
Sheet Author
First off - can you do formulas with repeatable fields within a repeatable section?  (Man - I hope that makes sense to someone) Here is the code below (it currently isn't working).  Do I have to add something to the field descriptions when adding (like repeating_pack1_...)?     <fieldset name="repeating_pack1" class="repeating_pack1">         <div class="sheet-row">             <div class="sheet-col-1-11"><input type="text" name="attr_pack1_qty" /></div>             <div class="sheet-col-1-3"><input type="text" name="attr_pack1_item" /></div>             <div class="sheet-col-1-6"><input type="text" name="attr_pack1_SEU-hr" /></div>                         <div class="sheet-col-1-6"><input type="text" name="attr_pack1_cost" /></div>             <div class="sheet-col-1-6"><input type="text" name="attr_pack1_mass" /></div>            <div class="sheet-col-1-16 sheet-center" style="padding-top:3px"><input type="checkbox" checked style="text-align:left;width:15px;height:15px" name="attr_pack1_on" value="1"/></div>             <input type="hidden" name="attr_pack1-SEU" value='@{pack1-SEU-hr}*@{pack1-on}">         </div>     </fieldset>
1474585459

Edited 1474586075
vÍnce
Pro
Sheet Author
Yes. I believe your code was just a little off.(haven't tested this...)   You don't need to name your fieldset, just use class="repeating_FOO" .  You also had a single quote and a double quote  in the last input. update/edit: just "dressed-up" the code a little for the forum <fieldset class="repeating_pack1"> <div class="sheet-row">         <div class="sheet-col-1-11"><input type="text" name="attr_pack1_qty" /></div>         <div class="sheet-col-1-3"><input type="text" name="attr_pack1_item" /></div>         <div class="sheet-col-1-6"><input type="text" name="attr_pack1_SEU-hr" /></div>                     <div class="sheet-col-1-6"><input type="text" name="attr_pack1_cost" /></div>         <div class="sheet-col-1-6"><input type="text" name="attr_pack1_mass" /></div>         <div class="sheet-col-1-16 sheet-center" style="padding-top:3px"><input type="checkbox" checked style="text-align:left;width:15px;height:15px" name="attr_pack1_on" value="1" /></div> <input type="hidden" name="attr_pack1-SEU" value="@{pack1-SEU-hr}*@{pack1-on}" /> </div>        </fieldset>
1474586411
Falcon
Pro
Sheet Author
I see the error - so besides the syntax error - I did it correctly?
1474586751

Edited 1474586840
vÍnce
Pro
Sheet Author
Black Falcon said: I see the error - so besides the syntax error - I did it correctly? I believe so. Can you pull a value for @{selected|repeating_pack1_$0_-SEU} ?  Given you have added something for row 0.
1474587431
Falcon
Pro
Sheet Author
It's working but it TAS isn't showing the number. on("change:repeating_pack1",function(){     TAS.repeatingSimpleSum('pack1','pack1_SEU-hr',"p1_total_SEU");     TAS.repeatingSimpleSum('pack1','pack1_cost',"p1_total_cost");     TAS.repeatingSimpleSum('pack1','pack1_mass',"p1_total_mass"); }); on("remove:repeating_pack1",function(){     TAS.repeatingSimpleSum('pack1','pack1_SEU-hr',"p1_total_SEU");     TAS.repeatingSimpleSum('pack1','pack1_cost',"p1_total_cost");     TAS.repeatingSimpleSum('pack1','pack1_mass',"p1_total_mass"); });
1474587487
Falcon
Pro
Sheet Author
Revised code:     <fieldset class="repeating_pack1">         <div class="sheet-row">             <div class="sheet-col-1-11"><input type="text" name="attr_pack1_qty" /></div>             <div class="sheet-col-1-3"><input type="text" name="attr_pack1_item" /></div>             <div class="sheet-col-1-6"><input type="text" name="attr_pack1_SEU" /></div>                         <div class="sheet-col-1-6"><input type="text" name="attr_pack1_cost" /></div>             <div class="sheet-col-1-6"><input type="text" name="attr_pack1_mass" /></div>             <div class="sheet-col-1-16 sheet-center" style="padding-top:3px"><input type="checkbox" checked style="text-align:left;width:15px;height:15px" name="attr_pack1_on" value="1"/></div>             <input type="hidden" name="attr_pack1_SEU-hr" value="[[@{pack1_SEU}*@{pack1_on}]]">         </div>     </fieldset>
1474587552

Edited 1474587573
Falcon
Pro
Sheet Author
TAS was adding it up correctly (without the formula) but I think it only does simple sum when it is a single number - not a formula.  I tried to put [[]] around it but I don't think that matters since it does convert it to a number until after it gets into sheet worker
1474587919
vÍnce
Pro
Sheet Author
I was able to cobble together some useage of TAS on the 1e sheet, but I will have to bow to other's sheet worker expertise.  I would think you give pack1_SEU-hr a value="" then do the actual math in the sheet workers.
1474588030
Falcon
Pro
Sheet Author
Vince said: I was able to cobble together some useage of TAS on the 1e sheet, but I will have to bow to other's sheet worker expertise.  I would think you give pack1_SEU-hr a value="" then do the actual math in the sheet workers. yeah - but I was trying to avoid it.  I was hoping that you could do the math prior.  I am a beginner at sheet workers. Yeah - I have been trying to use your 1e sheet If/elseif in my own stuff.  Pretty awesome.
1474590528

Edited 1474590727
vÍnce
Pro
Sheet Author
You can keep most calcs out of sheet workers, however if you want to tally up repeating items you'll need sheet workers.  I had a hard time understanding how to properly implement TAS.  I used it for some things, but ultimately just created some on("change: functions for some basic attribute math.   Example I did this to figure some weight totals (this can be done with repeating attributes as well.  Obviously the attribute names would be different.  The  wiki  has some good info on dealing with repeating attributes in sheet workers); on('change:pp change:gp change:ep change:sp change:cp change:armor_weight change:armor_cost', function(){ getAttrs(['pp','gp','ep','sp','cp','armor_weight','armor_cost'], function(values){       setAttrs({         total_coin_weight: (parseInt(values.pp) + parseInt(values.gp) + parseInt(values.ep) + parseInt(values.sp) + parseInt(values.cp)), total_armor_weight: (parseInt(values.armor_weight)), total_armor_cost: (parseInt(values.armor_cost)).toFixed(2)       });    }); });