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

API Error Lock when using 5e OGL Ammo Tracking

So I set up a player's sheet to use ammo tracking following the steps in the wiki, and it worked for one shot, then stopped. I checked the API page to see an error lock with a bunch of stuff about firebase: Error: Firebase.update failed: First argument contains NaN in property 'current' Error: Firebase.update failed: First argument contains NaN in property 'current' 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) At first I thought it was to do with the fact that I edited the basic 5e OGL sheet (added a couple templates, added a blind roll option in combination with another script - all worked fine). So, I switched back to the basic sheet, tried again, and it still gave that exact same error. The rest of the commands for the companion script seem to work, so I tried making another character, and it worked fine (I also noticed that the styling was different than when I was using the edited sheet, but that's besides the point). Still broke when using it on the original character, so I changed the name of the original then set up another character with that name, and that also broke it, same error as before. Only notable difference between the ones that worked and ones that didn't was that my player had put a hyphen in their character's name, so I think that's what's breaking it? Any help is appreciated though.
So the specific error you are encountering an attribute with a current value that is Not A Number (NAN). So what I would ask is you check the resource you are decrementing for the ammo and ensure that it has a value greater than 1. When creating a new item on the character sheet, it looks  like there is one of that item, but it is the placeholder value and not actually set within the system. If you manually set this value, to a value of 1 or greater, my theory is that the API will work successfully.
1534776595
The Aaron
Pro
API Scripter
If you rename the character to remove the -, does it start working?  The actual error above is an invalid value getting written into the attribute's "current" property. It makes it a bit harder to track down where it's happening.  My guess would be either line 498: ammoresource.set({current: ammoresource.get("current") - ammonum}); 503: ammoitem.set({current: ammoitem.get("current") - ammonum}); or 508: totalweight.set({current: totalweight.get("current") - (ammoweight.get("current") * ammonum)}); if any of those terms is not set, it will cause NaN to be placed in the attribute's current property, causing the above crash. My suggestion would be to make sure you have numbers in all the right places regarding ammo (quantity, weight, number used, etc).  Worst case, remove the ammo and weapon and try adding it again.
1534780342

Edited 1534781355
check the resource you are decrementing for the ammo and ensure that it has a value greater than 1 Each time I tested with a new character I set the amount to 20, so I don't think that's it. If you rename the character to remove the -, does it start working? Not for that character, I get the same error. Works when creating entirely new characters without the -. make sure you have numbers in all the right places regarding ammo (quantity, weight, number used, etc) I just dragged arrows from the 5e compendium and then changed the amount, that should be fine I think? ETA: Even when it is working, it also isn't displaying the remaining number of arrows. ETA#2: Found the problem. My player added "lb" after the weight, causing the NaN error when it tried to readjust the total weight. This wasn't replicated when I remade characters to test as I just used the compendium entries (still isn't displaying remaining resources, but I think that's a sheet thing as attack/damage templates also look a bit off).
1534782370
The Aaron
Pro
API Scripter
Ah, that's great news and great info!  That would definitely cause line 508 to blow up.  Should be easily fixed with the addition of a parseFloat() call in the future.