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

Repeating bug with Tracker Jacker script

While playing my game tonight, I ran into the same error repeatedly in the TrackerJacker script from the API wiki. Having to restart the sandbox multiple times during combat. Error: Firebase.update failed: First argument contains NaN in property 'bar1_value' Error: Firebase.update failed: First argument contains NaN in property 'bar1_value' at Ba (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:9:186) at Ba (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:10:207) at Aa (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:8:462) at Ea (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:10:403) at J.update (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:146:318) at TrackedObj._doSave (/home/node/d20-api-server/api.js:850:27) at later (/home/node/d20-api-server/node_modules/underscore/underscore.js:892:31) at Timeout._onTimeout (/home/node/d20-api-server/node_modules/underscore/underscore.js:829:19) at ontimeout (timers.js:386:14) at tryOnTimeout (timers.js:250:5) I don't have much understanding of coding, so hopefully somebody here can tell me what I'm doing wrong.
1532122005
The Aaron
Pro
API Scripter
Some script is writing an invalid value into bar1_value of some token. When Firebase attempts to synchronize that data across all the connected players, it crashes.   What scripts do you have installed?
Jip said: While playing my game tonight, I ran into the same error repeatedly in the TrackerJacker script from the API wiki. Having to restart the sandbox multiple times during combat. Error: Firebase.update failed: First argument contains NaN in property 'bar1_value' Error: Firebase.update failed: First argument contains NaN in property 'bar1_value' at Ba (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:9:186) at Ba (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:10:207) at Aa (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:8:462) at Ea (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:10:403) at J.update (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:146:318) at TrackedObj._doSave (/home/node/d20-api-server/api.js:850:27) at later (/home/node/d20-api-server/node_modules/underscore/underscore.js:892:31) at Timeout._onTimeout (/home/node/d20-api-server/node_modules/underscore/underscore.js:829:19) at ontimeout (timers.js:386:14) at tryOnTimeout (timers.js:250:5) I don't have much understanding of coding, so hopefully somebody here can tell me what I'm doing wrong. Does the tokens have a numerical value in the middle bubble?
These are the scripts I have installed. @theodore, the value I have in the middle bubble is tied to the hp of the sheets of players, and set to a 11/11 for the NPCs without being tied to a sheet. throughout combat, some of the NPCs got reduced to 0hp.
Okay, so I just tried to test what the exact moment of crashing seemed to be, and it looks like the sandbox crashes the moment I reduce the HP of one of the NPCs. 
Alright, I found the culprit. It is the TempHP.js&nbsp; <a href="https://app.roll20.net/forum/post/138626/script-automatic-temp-hp-management/?pageforid=138626#post-138626" rel="nofollow">https://app.roll20.net/forum/post/138626/script-automatic-temp-hp-management/?pageforid=138626#post-138626</a> This one seemed to be causing all the crashes. Glad to have found the issue. Is there a version of this script that does not crash everything by any chance? :P
1532123330
The Aaron
Pro
API Scripter
I'd suggest disabling each script and trying it again until you don't get the crash anymore. That will indicate what script is causing the issue.&nbsp; My guess is either TempHP.js or HitDies.js.&nbsp; Something that is operating on the event 'change:graphic' or one of it's derivatives.
Thanks, it was TempHP.js. Now I need to find a new script that detracts Temp HP before main HP.
1532124053
The Aaron
Pro
API Scripter
Try this version: /** * Automatically removes temp HP if they exist. * * When a token has its HP reduced the script checks to see if there are any * temp HP available. If it does those are removed first and the real HP is * updated to reflect the temp HP absorbing the hit. * * TEMP_BAR_ID - The bar used to track temp HP [1, 2, 3] * HP_BAR_ID - The bar used top track real HP [1, 2, 3] */ on('ready', ()=&gt;{ // =========&gt; SET AS NEEDED &lt;=========== const TEMP_BAR_ID = 2; const HP_BAR_ID = 1; // ===================================== const barName = `bar${HP_BAR_ID}_value`; const tempBarName = `bar${TEMP_BAR_ID}_value`; on("change:token", (obj, prev) =&gt; { const prevHpValStr = prev[barName]; let prevHpVal = parseInt(prevHpValStr, 10); if (Number.isNaN(prevHpVal) ) { log("WARN: Previos bar " + HP_BAR_ID + " does not contain a number: '" + prevHpValStr + "'"); return; } const hpValStr = obj.get(barName); let hpVal = parseInt(hpValStr,10); if (Number.isNaN(hpVal) ) { log("WARN: Bar " + HP_BAR_ID + " does not contain a number: '" + hpValStr + "'"); return; } // assure numbers prevHpVal = prevHpVal || 0; hpVal = hpVal || 0; if (prevHpVal &gt; hpVal) { const tmpHpVal = parseInt(obj.get(tempBarName)); if ( !Number.isNaN(tmpHpVal) ) { const hpChange = prevHpVal - hpVal; const remainingTmp = (tmpHpVal||0) - hpChange; if (remainingTmp &gt; 0) { obj.set(tempBarName, (remainingTmp||0)); obj.set(barName, (prevHpVal||0)); } else { const remainingHp = prevHpVal + remainingTmp; obj.set(tempBarName, 0); obj.set(barName, (remainingHp||0)); } } } }); });
That seems to be working so far, thanks a bunch Aaron. :thumbsup:
1532124560
The Aaron
Pro
API Scripter
Cool!&nbsp; I didn't test the rewrite, but it looked right. =D