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

[Help] Trying to understand sheetworkers, TAS, and how to place them for my sheet

1484247918
Pat S.
Forum Champion
Sheet Author
I have been studying the sheet workers (searching and reading threads in the forum), looking at TAS script (even got it placed in a test sheet), and reading the various samples given on the TAS github (specifically the simplesum) but I do not have a clue on how to get it to work on my sheet (it is giving me a headache trying to understand it). The main reason for my desire to learn (at least get it working) is to take my inventory sections ( repeating fields) and total up the weight for encumbrance output (non repeating field) Now I'm wondering where or what do I do with the sample? <h3>Inventory</h3> <div class="inventory-row headers">     <div class="name" >Item</div>     <div class="quantity" >Qty</div>     <div class="weight" >Weight</div>     <div class="totalweight" >Total Weight</div>     <div class="cost" >Cost($)</div>     <div class="runningtotal" >Running Total($)</div> </div> <fieldset class="repeating_inventory"> <div class="inventory-row"> <input class="name" type="text" name="attr_item" placeholder="item name" title="name" /> <input class="quantity" type="text" name="attr_quantity" value="0" title="quantity" /> <input class="weight" type="text" name="attr_weight" value="0" title="weight" /> <input class="totalweight" type="text" name="attr_totalweight" value="0" title="totalweight" /> <input class="cost" type="text" name="attr_cost" value="0" title="cost" /> <input class="runningtotal" type="text" name="attr_runningtotal" value="0" title="running total" /> </div> </fieldset> <div class="footer"> <div class="total">Total Weight<br><input class="sumtotalweight" type="text" name="attr_total_weight" value="0" title="total weight" /></div> <div class="total">Total Cost<br><input class="sumtotalcost" type="text" name="attr_total_cost" value="0" title="total cost" /></div> <div class="total">Summary:<br><textarea class="summary" type="textarea" name="attr_summary" title="summary"/></textarea> </div> Do I take this example and work it into my code (just the first tab shown as the rest are duplicates) <!--Inventory --> <div class="sheet-section-inventory"> <div class="sheet-row "> <!-- Loot--> <div class="sheet-col-1-2 sheet-padr"> <h4 class="sheet-center">Coin Carried </h4> <div class="sheet-row sheet-sub-header sheet-center"> <div class="sheet-col-1-4 sheet-center sheet-small-label">CP</div> <div class="sheet-col-1-4 sheet-center sheet-small-label">SP</div> <div class="sheet-col-1-4 sheet-center sheet-small-label">GP</div> <div class="sheet-col-1-4 sheet-center sheet-small-label">Total Value(GP)</div> </div> <div class="sheet-row sheet-center"> <div class="sheet-col-1-4" title="Copper Pieces"><input type="number" name="attr_cp" value="0" min="0" step="1"></div> <div class="sheet-col-1-4" title="Silver Pieces"><input type="number" name="attr_sp" value="0" min="0" step="1"></div> <div class="sheet-col-1-4" title="Gold Pieces"><input type="number" name="attr_gp" value="0" min="0" step="1"></div> <div class="sheet-col-1-4" title="Total (in Gold Pieces)"><input type="number" name="attr_money_total_gp" value="(@{cp} / 100) + (@{sp} / 10) +  @{gp} " disabled="disabled"></div> </div> <h4 class="sheet-center">Encumbrance </h4> <div class="sheet-row sheet-sub-header"> <div class="sheet-col-1-4 sheet-center sheet-small-label">Equipment</div> <div class="sheet-col-1-4 sheet-center sheet-small-label">Coin</div> <div class="sheet-col-1-4 sheet-center sheet-small-label">Other</div> <div class="sheet-col-1-4 sheet-center sheet-small-label sheet-padr">Total</div> </div> <div class="sheet-row"> <div class="sheet-col-1-4 sheet-center"><input type="number" name="attr_inventory_weight" value="0" title="Total up your equipment Worn and Carried then place amount here"></div> <div class="sheet-col-1-4 sheet-center"><input type="number" name="attr_coin_weight" value="((@{CP} + @{SP} + @{GP})/10)" disabled="disabled"></div> <div class="sheet-col-1-4 sheet-center"><input type="number" name="attr_other_weight" value="0" min="0"></div> <div class="sheet-col-1-4 sheet-center sheet-padr"><input type="number" name="attr_total_weight" value="@{inventory_weight} + @{coin_weight} + @{other_weight}" disabled="disabled"></div> </div> </div> <!-- Inventory tab -->             <div class="sheet-col-1-2">                 <h4 class="sheet-center">Treasure Notes </h4> <textarea name="attr_lootnotes"></textarea> </div> </div> <h4 class="sheet-center">Equipment </h4> <input type="radio" name="attr_inventorytab" class="sheet-inventorytab sheet-inventorytab1" value="1" title="Page 1" checked="checked" /> <span class="sheet-inventorytab sheet-inventorytab1">Worn</span> <input type="radio" name="attr_inventorytab" class="sheet-inventorytab sheet-inventorytab2" value="2" title="Page 2" /> <span class="sheet-inventorytab sheet-inventorytab2">Carried</span> <input type="radio" name="attr_inventorytab" class="sheet-inventorytab sheet-inventorytab3" value="3" title="Page 3" /> <span class="sheet-inventorytab sheet-inventorytab3">Transportation</span> <input type="radio" name="attr_inventorytab" class="sheet-inventorytab sheet-inventorytab4" value="4" title="Page 4" /> <span class="sheet-inventorytab sheet-inventorytab4">Elsewhere</span> <input type="radio" name="attr_inventorytab" class="sheet-inventorytab sheet-inventorytab99" value="99" title="Show All" /> <span class="sheet-inventorytab sheet-inventorytab99">Show All</span> <span class="sheet-spacer"></span>              <!-- Inventory Page 1--> <div class="sheet-inventory-page1"> <input type="text" class="sheet-center sheet-sub-header" name="attr_tabinvtitle1" value="What is being worn such as armor or clothing" disabled="disabled"> <div class="sheet-row sheet-sub-header"> <div class="sheet-col-1-4 sheet-center sheet-small-label sheet-padl">Name</div> <div class="sheet-col-1-12 sheet-center sheet-small-label">Qty</div> <div class="sheet-col-1-12 sheet-center sheet-small-label">Uses</div> <div class="sheet-col-1-12 sheet-center sheet-small-label">Weight</div> <div class="sheet-col-1-2 sheet-center sheet-small-label sheet-padl">Notes</div> </div> <fieldset class="repeating_inventtab1"> <div class="sheet-row"> <div class="sheet-col-1-4 sheet-small-label sheet-left"><input type="text" name="attr_itemname"></div> <div class="sheet-col-1-12 sheet-padl sheet-center"><input type="number" name="attr_itemquantity"></div> <div class="sheet-col-1-12 sheet-padl sheet-center"><input type="number" name="attr_itemuses"></div> <div class="sheet-col-1-12 sheet-padl sheet-center"><input type="number" name="attr_itemwornenc"></div> <div class="sheet-col-1-2 sheet-padl sheet-small-label sheet-left"><input type="text" name="attr_itemdesc"></div> </div> </fieldset> </div> or what?
1484280859
Finderski
Pro
Sheet Author
Compendium Curator
Not sure I understand the question completely...but I think you're asking, is there anything you need to do to incorporate the TAS with your inventory stuff (i.e. modify your HTML)... If I'm understanding that correctly, you don't need to modify your HTML other than to add the TAS code within your your script tags for the Sheet Workers.  Then you create your own sheet worker (again within the script tags) and call the TAS function.  Here's the code I have for the Savage Worlds (Tabbed) sheet: // Calculate Armor Weights on('change:repeating_armor remove:repeating_armor',function(){ TAS.repeatingSimpleSum('armor','ArmorTypeWeight','armortotalweightcarried'); }); // Calculate Melee Weapon Weights on('change:repeating_meleeweapons remove:repeating_meleeweapons',function(){ TAS.repeatingSimpleSum('meleeweapons','WeaponWeight','meleetotalweightcarried'); }); // Calculate Range Weapon Weights on('change:repeating_rangeweapons remove:repeating_rangeweapons',function(){ TAS.repeatingSimpleSum('rangeweapons','RWeaponWeight','rangedtotalweightcarried'); }); // Calculate Gear Weights on('change:repeating_gear remove:repeating_gear',function(){ TAS.repeatingSimpleSum('gear','itemWeight','geartotalweightcarried'); }); So, I have repeating sections for Armor, Melee Weapons, Ranged Weapons and general Gear.  Each of those repeating sections has a weight field within it (i.e. ArmorTypeWeight, WeaponWeight, RWeaponWeight, and itemWeight). Then outside each of those repeating sections I have a total weight field where I store the sum for each of those repeating sections (e.g. meleetotalweightcarried is the sum field that sits outside of the repeating section and stores the value of the sum). I hope this helps.
1484282017
Pat S.
Forum Champion
Sheet Author
So all I need is the TAS script and none of the sample code that is shown (all the html stuff) that was shown as an example on his github? I'm just not understanding this at all.
1484298682
Finderski
Pro
Sheet Author
Compendium Curator
Correct, all you need is TAS. The sample HTML was simply to show how to use TAS.
1484318335
Pat S.
Forum Champion
Sheet Author
I'm still at a lost on how to get what I want to total and display on the sheet. I just want my inventory weight (nothing else) to total up and display the total on the sheet. I have 2 repeating fields (worn and carried) that would impact the character and I just want it to autototal the weight and display it in another field on the character sheet. I'm not a coder and this is just frustrating me while giving me a headache.
1484323295

Edited 1484323311
Finderski
Pro
Sheet Author
Compendium Curator
Ok, let's take a step back and make sure I understand what you have and what you want... You have already copy/pasted the TAS script into the sheet workers section of the character sheet, correct? Next, you want to total the worn and carried? Does that mean you want to separate sums displayed in two separate places? What are the field names fo the fields you want to sum? What are the field names you want to store the sum-totals in? what are the names of the repeating sections? For this, we don't necessarily need the HTML code, we just need to know all the different parts. TAS only needs three things: the name of the repeating section, the field within that repeating section you want to sum, and the field where that sum should be stored. So, as an example, my sheet has a section called "repeating_gear", within that repeating section I have a field called attr_itemWeight (which is where I store the weight information for each item). I want the sum of all the itemWeight fields to be stored in a field (outside the repeating section) called geartotalweightcarried. With that, the TAS call is simply: // Calculate Gear Weights on('change:repeating_gear remove:repeating_gear',function(){ TAS.repeatingSimpleSum('gear','itemWeight','geartotalweightcarried'); }); Which says, when the the repeating section repeating_gear is changed (i.e. an item is added to it), or when something is removed from that section, then call the TAS function and feed it the repeating section (minus the repeating_, so the that's why it's just 'gear'), the fields I want summed (i.e. itemWeight), and where to store the sum (i.e. geartotalweightcarried).
1484360686
Pat S.
Forum Champion
Sheet Author
Ok, here is my attempt and I screwed up something. The two repeating fields are inventtab1 and inventtab2 and my output needs to go to totalloadcarried. I based what I have off your work on the SW tab sheet. What did I screw up or miss? // Calculate Worn Weight on('change:repeating_inventtab1 remove:repeating_inventtab1',function(){ TAS.repeatingSimpleSum('inventtab1','itemwornenc','itemwornenctotal'); }); // Calculate Carried Weight on('change:repeating_inventtab2 remove:repeating_inventtab2',function(){ TAS.repeatingSimpleSum('inventtab2','itemcarriedenc','itemcarriedenctotal'); }); //Calculate Total Load Carried on("sheet:opened change:itemwornenctotal change:itemcarriedenctotal",function(){ //'use strict'; getAttrs(["itemwornenctotal", "itemcarriedenctotal", "rangedtotalweightcarried", "geartotalweightcarried"], function(lvalue) { //@{itemwornenctotal} + @{itemcarriedenctotal} var worn = parseInt(lvalue.itemwornenctotal)||0; var carried = parseInt(lvalue.itemcarriedenctotal)||0;       setAttrs({ totalloadcarried: worn + carried });     }); });
1484391165
Finderski
Pro
Sheet Author
Compendium Curator
Can you describe what's happening? Is itemwornenctotal calculating properly? What about itemcarriedenctotal? If those are calculating properly, then I'm assuming the entire problem lies with the Calculate Total Load Carried...if that's not the case, then we may need a view of your html for the inventory section (so we can see all the fields called). However, before posting all the html, there may be some things you can do to help troubleshoot as well.  Add a console.log to your Load Carried bit, so it looks something like this: //Calculate Total Load Carried on("sheet:opened change:itemwornenctotal change:itemcarriedenctotal",function(){ //'use strict'; getAttrs(["itemwornenctotal", "itemcarriedenctotal", "rangedtotalweightcarried", "geartotalweightcarried"], function(lvalue) { console.log("Item Worn Total: " + lvalue.itemwornenctotal); console.log("Item Worn Total: " + lvalue.itemcarriedenctotal); var worn = parseInt(lvalue.itemwornenctotal)||0; var carried = parseInt(lvalue.itemcarriedenctotal)||0; setAttrs({ totalloadcarried: worn + carried }); }); }); And, also show grab the output from the console log itself. On Chrome that's under: View=>Developer=>Developer Tools; then across the top is a menu, you'd click on Console. The console log will show a bunch of stuff, but I don't think we need it all, just the stuff pertaining to what you're doing here (you can grab the whole thing if it's easier, but...), so you can look for "Triggering for..."  That means you'll need to trigger the sheet worker by changing one of the values that kicks off the sheet worker; in this case, add or remove an item with weight so the itemwornenctotal or itemcarriedenctotal changes. The output would look something like this (in the console): Triggering for change:loadlimitmulitplier sheetsandboxworker.js?20160926:57 Triggering for change:loadlimitmulitplier_max app.js?1484245871:38 Querytest took until 45ms app.js?1484245871:38 Attribute cache compliation took until 46ms app.js?1484245871:38 Set values (including auto-calcuating variables) took until 63ms app.js?1484245871:38 strength value: 6 VM28:749 stMod value: undefined VM28:750 LL Multiplier: 8 VM28:751 LL Modifier: 0 VM28:752 Really updating character sheet values app.js?1484245871:38 That's the console log for my sheet, so your values and variables will be different of course; but that will allow us to see what values are being passed where and at what point the script breaks.
1485128925
Pat S.
Forum Champion
Sheet Author
I did what you said and got this Really updating character sheet values app.js?1484846757:39 Foudn a pre-defined key order! app.js?1484846757:38 Setting up repeating sections took until 8ms app.js?1484846757:38 Finding list of dirty attributes took until 9ms app.js?1484846757:38 Querytest took until 9ms app.js?1484846757:38 Attribute cache compliation took until 10ms app.js?1484846757:38 Set values (including auto-calcuating variables) took until 12ms app.js?1484846757:38 Took 13ms app.js?1484846757:38 which means I have something screwed up wrong.