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

Problem with sum of repeating rows

1618501377
.Hell
Sheet Author
Hey, I posted this issue already in the CharSheet section but this might be the better place. If anyone can help with this you would make me happy :) <a href="https://app.roll20.net/forum/post/9987337/problem-with-sum-of-repeating-rows" rel="nofollow">https://app.roll20.net/forum/post/9987337/problem-with-sum-of-repeating-rows</a>
1618535667

Edited 1618535740
David
Sheet Author
Use the Aaron Sheet.&nbsp; <a href="https://github.com/shdwjk/TheAaronSheet" rel="nofollow">https://github.com/shdwjk/TheAaronSheet</a> &nbsp; it does all the work for you. Specifically the simple sum&nbsp; <a href="https://github.com/shdwjk/TheAaronSheet#example-1-tasrepeatingsimplesum" rel="nofollow">https://github.com/shdwjk/TheAaronSheet#example-1-tasrepeatingsimplesum</a>
1618591053
.Hell
Sheet Author
Thanks for the tip. I looked into it and did it as follows: on('change:repeating_armors remove:repeating_armors', function() { TAS.repeating('armors') //&lt; set the repeating group we are using .attrs('armor_total') //&lt; specify we want access to the total_weight attribute .fields('armorvalue','armorworn') //&lt; specify we want the item and weight repeating fields .execute(); //&lt; tell TAS it has been configured and can run now. }); But it does not work. Further tips are apprectiated
1619346636
.Hell
Sheet Author
Anyone got any idea what I might be missing?
1619400091

Edited 1619409964
vÍnce
Pro
Sheet Author
Stupid question; the complete TAS is installed within your sheetworker script right? I am not skilled with sheetworkers but...&nbsp; see if this works.&nbsp; on('change:repeating_armors remove:repeating_armors', function(){ TAS.repeating('armors') .attrs('armor_total') .fields('armorvalue', 'armorworn') .reduce(function(m,r){ m.armorvalue+=(r.F.armorvalue*r.I.armorworn); r.D[0].armor_total=(r.F.armorvalue*r.I.armorworn); return m; }, &nbsp;&nbsp;&nbsp;&nbsp;{armorvalue:0,armorworn:0, desc: []}, function (m,r,a){ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a.armor_total=m.armorvalue; }) .execute(); });
1619452547
.Hell
Sheet Author
Thanks vince, with your help and little modification of your snippet I got it mostly to run. on('change:repeating_armors remove:repeating_armors', function(){ TAS.repeating('armors') .attrs('armor_total') .fields('armorvalue', 'armorworn') .reduce(function(m,r){ if(r.armorworn === "on") { m.armorvalue += r.F.armorvalue; } return m; }, {armorvalue:0,armorworn:0, desc: []}, function (m,r,a){ a.armor_total=m.armorvalue; }) .execute(); }); The last problem left is, that the field where I display the calculated value is not allowed to be disabled. If it is disabled the value is not updated...
1619453881
.Hell
Sheet Author
The solution for the updating problem is: the field is NOT disabled the CSS class of the field to update needs pointer-events: none;
1619465110
vÍnce
Pro
Sheet Author
Great.&nbsp; I think you can also use a readonly input for your total attribute.