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 :)
https://app.roll20.net/forum/post/9987337/problem-with-sum-of-repeating-rows
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 :)
https://app.roll20.net/forum/post/9987337/problem-with-sum-of-repeating-rows
Use the Aaron Sheet. https://github.com/shdwjk/TheAaronSheet it does all the work for you. Specifically the simple sum https://github.com/shdwjk/TheAaronSheet#example-1-tasrepeatingsimplesum
Thanks for the tip. I looked into it and did it as follows:
on('change:repeating_armors remove:repeating_armors', function() {
TAS.repeating('armors') //< set the repeating group we are using
.attrs('armor_total') //< specify we want access to the total_weight attribute
.fields('armorvalue','armorworn') //< specify we want the item and weight repeating fields
.execute(); //< tell TAS it has been configured and can run now.
});
But it does not work. Further tips are apprectiated
Stupid question; the complete TAS is installed within your sheetworker script right?
I am not skilled with sheetworkers but... see if this works.
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; }, {armorvalue:0,armorworn:0, desc: []}, function (m,r,a){ a.armor_total=m.armorvalue; }) .execute(); });
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...