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

3.5 Character sheet edit to include gold weight to total carried weight, need help/tips

1721899700

Edited 1721901176
I haven't ever coded in HTML but basically I'm here on('change:repeating_equipment', function(){    TAS.repeating('equipment')         .attrs('totalequipmentweight','totalequipmentcost','summary')         .fields('equipmentname','equipmentquantity','equipmentweight','equipmenttotalweight','equipmentcost','equipmenttotalcost')         .reduce(function(m,r){             m.equipmentweight+=(r.F.equipmentweight*r.I.equipmentquantity);             r.D[3].equipmenttotalweight=(r.F.equipmentweight*r.I.equipmentquantity);             m.equipmentcost+=(r.F.equipmentcost*r.I.equipmentquantity);             r.D[2].equipmenttotalcost=(r.F.equipmentcost*r.I.equipmentquantity);             m.desc.push(r.equipmentname+(r.I.equipmentquantity>1 ? ' (x'+r.S.equipmentquantity+')' : ''));             return m;         },{equipmentweight:0,equipmentcost:0, desc: []},function(m,r,a){             a.summary=m.desc.join(', ');             a.D[3].totalequipmentweight=m.equipmentweight;             a.D[2].totalequipmentcost=m.equipmentcost;         })         .execute(); }); I added an additional currency slot and changed names but it functions that same as the standard stuff, just had to update the translation file to fit. <div class="table-sheet-row">                                 <span class="table-sheet-data-center"><input type="text" name="attr_beads" title="Lead bead" style="width: 96px;"><br><span data-i18n="lead-bearings-iu">CP</span></span>                                 <span class="table-sheet-data-center"><input type="text" name="attr_bits" title="Ceramic bit" style="width: 96px;"><br><span data-i18n="ceramic-bits-iu">SP</span></span>                                 <span class="table-sheet-data-center"><input type="text" name="attr_ceramic" title="Ceramic piece" style="width: 96px;"><br><span data-i18n="ceramic-pieces-iu">GP</span></span>                                 <span class="table-sheet-data-center"><input type="text" name="attr_silver" title="Silver" style="width: 96px;"><br><span data-i18n="silver-pieces-iu">PP</span></span>                 <span class="table-sheet-data-center"><input type="text" name="attr_gold" title="Gold" style="width: 96px;"><br><span data-i18n="gold-pieces-iu">PP</span></span>                             </div> I believe I need to take "attr_beads" reference it somewhere and somehow so the weight equation can pull the info I'm asking it? then I need to add all coins together /50 then add to I believe this "r.D[3].equipmenttotalweight=(r.F.equipmentweight*r.I.equipmentquantity);"? rn I'm stuck trying to figure out how to get the attributes recognized and then I think I'll be stuck on the order of operation to get it too calc right. How close am I? I wish I was back messing with macros right about now haha. updating this line to include the coins .fields('equipmentname','equipmentquantity','equipmentweight','equipmenttotalweight','equipmentcost','equipmenttotalcost','beads','bits','ceramic','silver','gold') then add them to the right equation?  r.D[3].equipmenttotalweight=(r.F.equipmentweight*r.I.equipmentquantity+(beads+bits+ceramic+silver+gold)/50); it doesn't work so I'm kind of stumped
1721921126

Edited 1721946938
vÍnce
Pro
Sheet Author
I'm on my phone ATM, but you might find GiGs RepeatingSum script/function a little easier to use than TAS(the Aaron Script) which is a super powerful addition for any sheet but probably overkill for a single calc like this. <a href="https://wiki.roll20.net/RepeatingSum" rel="nofollow">https://wiki.roll20.net/RepeatingSum</a> I'll circle back later when I'm home either way.&nbsp; Cheers
1721952647
vÍnce
Pro
Sheet Author
had a chance to take a look.&nbsp; You are very close.&nbsp; Try this; on('change:repeating_equipment change:beads change:bits change:ceramic change:silver change:gold', function(){ TAS.repeating('equipment') .attrs('totalequipmentweight','totalequipmentcost','summary','beads','bits','ceramic','silver','gold') .fields('equipmentname','equipmentquantity','equipmentweight','equipmenttotalweight','equipmentcost','equipmenttotalcost') .reduce(function(m,r){ m.equipmentweight+=(r.F.equipmentweight*r.I.equipmentquantity); r.D[3].equipmenttotalweight=(r.F.equipmentweight*r.I.equipmentquantity); m.equipmentcost+=(r.F.equipmentcost*r.I.equipmentquantity); r.D[2].equipmenttotalcost=(r.F.equipmentcost*r.I.equipmentquantity); m.desc.push(r.equipmentname+(r.I.equipmentquantity&gt;1 ? ' (x'+r.S.equipmentquantity+')' : '')); return m; },{equipmentweight:0,equipmentcost:0, desc: []},function(m,r,a){ a.summary=m.desc.join(', '); console.log(`beads:${a.beads} bits:${a.bits} ceramic:${a.ceramic} silver:${a.silver} gold:${a.gold}`); const beads =+ a.beads; const bits =+ a.bits; const ceramic =+ a.ceramic; const silver =+ a.silver; const gold =+ a.gold; const totalCurrencyWeight=(beads + bits + ceramic + silver + gold)/50; console.log(`totalCurrencyWeight:${totalCurrencyWeight}`); a.D[3].totalequipmentweight=m.equipmentweight + totalCurrencyWeight; a.D[2].totalequipmentcost=m.equipmentcost; }) .execute(); }); the .fields are for the repeating attributes.&nbsp; .attrs is for the non-repeating attributes.&nbsp; So I moved your currency attributes into .attrs&nbsp; I added a couple console.logs to help you see what's going on.
That's it! Seeing what you did make a lot of sense now. Thank you so much!