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] Sheetworker Woes

1543702178
Finderski
Pro
Sheet Author
Compendium Curator
So, I've been fighting this most of the day and decided to throw the towel in... Here's my code: on("change:repeating_armor:armortypeweight change:repeating_armor:armorcarried", function(eventInfo) { let weightDiff = 0; getAttrs(["repeating_armor_ArmorTypeWeight","repeating_armor_ArmorCarried","armortotalweightcarried", function(value) { if (eventInfo.sourceAttribute.slice(-15) === "armortypeweight") { console.log("Made it to Armor Type Weight Change"); //Armor Weight changed let newWeight = parseFloat(eventInfo.newValue) || 0; let oldWeight = parseFloat(eventInfo.previousValue) || 0; if (value.repeating_armor_ArmorCarried === "0") { //Armor wasn't Carried weightDiff = 0; } else { //Armor was Carried weightDiff = newWeight - oldWeight; } } else { //Armor Carried checkbox changed console.log("Armor Carried Checkbox Changed"); let armorWeight = value.repeating_armor_ArmorTypeWeight; if (eventInfo.newValue === "0") { //Armor was carried, but isn't any longer, need to remove the weight from Total weightDiff = armorWeight * -1; } else { //Need to add the weight to the Total weightDiff = armorWeight; } } let newTotalWeight = value.armortotalweightcarried + weightDiff; setAttrs({armortotalweightcarried: newTotalWeight}); }]); }); And for some reason, I get this error when I change one of those values... Really updating character sheet values app.js?1542653514:352 Setting up repeating sections took until 16ms app.js?1542653514:352 Finding list of dirty attributes took until 18ms sheetsandboxworker.js?1543701703092:683 DOMException: Failed to execute 'postMessage' on 'DedicatedWorkerGlobalScope': function(value) { &nbsp; &nbsp; &nbsp; &nbsp;if (eventInfo.sourceAttribute.slice(-15) === "armortypeweight") { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;con...&lt;omitted&gt;... } could not be cloned. &nbsp; &nbsp; at self.getAttrs (<a href="https://app.roll20.net/js/d20/sheetsandboxworker.js?1543701703092:158:3" rel="nofollow">https://app.roll20.net/js/d20/sheetsandboxworker.js?1543701703092:158:3</a>) &nbsp; &nbsp; at Array.eval (eval at messageHandler (<a href="https://app.roll20.net/js/d20/sheetsandboxworker.js?1543701703092:651:6" rel="nofollow">https://app.roll20.net/js/d20/sheetsandboxworker.js?1543701703092:651:6</a>), &lt;anonymous&gt;:412:6) &nbsp; &nbsp; at self.trigger (<a href="https://app.roll20.net/js/d20/sheetsandboxworker.js?1543701703092:110:37" rel="nofollow">https://app.roll20.net/js/d20/sheetsandboxworker.js?1543701703092:110:37</a>) &nbsp; &nbsp; at messageHandler (<a href="https://app.roll20.net/js/d20/sheetsandboxworker.js?1543701703092:655:6" rel="nofollow">https://app.roll20.net/js/d20/sheetsandboxworker.js?1543701703092:655:6</a>) app.js?1542653514:352 Querytest took until 19ms app.js?1542653514:352 Attribute cache compliation took until 20ms sheetsandboxworker.js?1543701703092:684 E rror: Failed to execute 'postMessage' on 'DedicatedWorkerGlobalScope': function(value) { &nbsp; &nbsp; &nbsp; &nbsp;if (eventInfo.sourceAttribute.slice(-15) === "armortypeweight") { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;con...&lt;omitted&gt;... } could not be cloned. &nbsp; &nbsp; at self.getAttrs (sheetsandboxworker.js?1543701703092:158) &nbsp; &nbsp; at Array.eval (eval at messageHandler (sheetsandboxworker.js?1543701703092:651), &lt;anonymous&gt;:412:6) &nbsp; &nbsp; at self.trigger (sheetsandboxworker.js?1543701703092:110) &nbsp; &nbsp; at messageHandler (sheetsandboxworker.js?1543701703092:655) app.js?1542653514:352 Set values (including auto-calcuating variables) took until 25ms app.js?1542653514:352 Took 26ms So, what have I done wrong here? &nbsp;
1543709132

Edited 1543710371
GiGs
Pro
Sheet Author
API Scripter
You dont have a ] on this line: getAttrs(["repeating_armor_ArmorTypeWeight","repeating_armor_ArmorCarried","armortotalweightcarried", function(value) { I dont know if this matters, but I also notice you are inconsistent on case in for armourtypeweight, here: if (eventInfo.sourceAttribute.slice(-15) === "armortypeweight") { and here: let armorWeight = value.repeating_armor_ArmorTypeWeight;
1543716828
Finderski
Pro
Sheet Author
Compendium Curator
GiGs said: You dont have a ] on this line: getAttrs(["repeating_armor_ArmorTypeWeight","repeating_armor_ArmorCarried","armortotalweightcarried", function(value) { I dont know if this matters, but I also notice you are inconsistent on case in for armourtypeweight, here: if (eventInfo.sourceAttribute.slice(-15) === "armortypeweight") { and here: let armorWeight = value.repeating_armor_ArmorTypeWeight; Thanks...so obvious. :-/ As for the inconsistency, that's only because eventInfo is always all lowercase, but when when using getAttrs, I use the case used in the html itself.
1543751109
GiGs
Pro
Sheet Author
API Scripter
ah right, of course, i havent used eventinfo much, i forgot it would be lower case.