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

Sheet Worker Scripts- Unexpected console errors

1511046322

Edited 1511115565
Missingquery
Pro
Sheet Author
API Scripter
I have been making some new additions to my sheet worker scripts, but when I run it, I get errors such as Error: Firebase.update failed: First argument contains NaN in property 'campaign-2299483-mMrc3Gc6R4HfabYCO7kZZA.char-attribs.char.-KzGIrdJCmoszxzp9R-J.-KzGIt-oKrnQDQbCqMdD.current' and FIREBASE WARNING: Exception was thrown by user callback. hg@<a href="https://app.roll20.net/assets/firebase.2.4.0.js:123:203" rel="nofollow">https://app.roll20.net/assets/firebase.2.4.0.js:123:203</a> jg/&lt;@<a href="https://app.roll20.net/assets/firebase.2.4.0.js:126:168" rel="nofollow">https://app.roll20.net/assets/firebase.2.4.0.js:126:168</a> Fb@<a href="https://app.roll20.net/assets/firebase.2.4.0.js:28:656" rel="nofollow">https://app.roll20.net/assets/firebase.2.4.0.js:28:656</a> jg@<a href="https://app.roll20.net/assets/firebase.2.4.0.js:126:134" rel="nofollow">https://app.roll20.net/assets/firebase.2.4.0.js:126:134</a> X.prototype.update@<a href="https://app.roll20.net/assets/firebase.2.4.0.js:258:369" rel="nofollow">https://app.roll20.net/assets/firebase.2.4.0.js:258:369</a> Backbone.sync/&lt;@<a href="https://app.roll20.net/assets/app.js?1510075463:3:1582" rel="nofollow">https://app.roll20.net/assets/app.js?1510075463:3:1582</a> c@<a href="https://app.roll20.net/assets/firebase.2.4.0.js:240:56" rel="nofollow">https://app.roll20.net/assets/firebase.2.4.0.js:240:56</a> h.Zb/&lt;@<a href="https://app.roll20.net/assets/firebase.2.4.0.js:201:708" rel="nofollow">https://app.roll20.net/assets/firebase.2.4.0.js:201:708</a> gc@<a href="https://app.roll20.net/assets/firebase.2.4.0.js:52:165" rel="nofollow">https://app.roll20.net/assets/firebase.2.4.0.js:52:165</a> cc@<a href="https://app.roll20.net/assets/firebase.2.4.0.js:30:216" rel="nofollow">https://app.roll20.net/assets/firebase.2.4.0.js:30:216</a> bc@<a href="https://app.roll20.net/assets/firebase.2.4.0.js:29:1198" rel="nofollow">https://app.roll20.net/assets/firebase.2.4.0.js:29:1198</a> Qi@<a href="https://app.roll20.net/assets/firebase.2.4.0.js:224:313" rel="nofollow">https://app.roll20.net/assets/firebase.2.4.0.js:224:313</a> h.Ib@<a href="https://app.roll20.net/assets/firebase.2.4.0.js:238:140" rel="nofollow">https://app.roll20.net/assets/firebase.2.4.0.js:238:140</a> h.Og@<a href="https://app.roll20.net/assets/firebase.2.4.0.js:240:244" rel="nofollow">https://app.roll20.net/assets/firebase.2.4.0.js:240:244</a> Backbone.sync@<a href="https://app.roll20.net/assets/app.js?1510075463:3:1243" rel="nofollow">https://app.roll20.net/assets/app.js?1510075463:3:1243</a> save@<a href="https://app.roll20.net/assets/base.js?1506440804:1:18264" rel="nofollow">https://app.roll20.net/assets/base.js?1506440804:1:18264</a> syncedSave@<a href="https://app.roll20.net/assets/app.js?1510075463:40:2273" rel="nofollow">https://app.roll20.net/assets/app.js?1510075463:40:2273</a> @<a href="https://app.roll20.net/assets/app.js?1510075463:47:6036" rel="nofollow">https://app.roll20.net/assets/app.js?1510075463:47:6036</a> in the console. Additionally, none of the expected attributes are created when their values are set, but the values are changed on the character sheet accordingly, and the stat total script I have running works perfectly fine regardless of the NaN errors. Here is the relevant code. Help? Note: the classlist variable does actually have content inside it, I just omitted it because I don't think it's relevant.
1511115591
Missingquery
Pro
Sheet Author
API Scripter
Please help, I really have no idea what's causing this. :(
1511189360

Edited 1511189385
chris b.
Pro
Sheet Author
API Scripter
When this happens to me, it means I tried setting NaN for a value instead of a number. This can happen when trying to convert an invalid string to a number, like "a", or if I just forgot to set that value. To track it down, i replaced getAttrs with a call to setWrapper, which looks at the values before passing them to setAttrs, so that it will print out the offending entry: note if you uncomment the a[k]="" line it will resets it from NaN to "" , which should cause roll20 to set it to the default value for that field. export function setWrapper(a,b,c){ _.each(a,function(v,k){ if (v!=='' && !v && (isNaN(v) || v === undefined)){ //a[k]=""; console.log("Setting NaN or undefined for attribute: "+k); } }); setAttrs(a,b,c); }