
Note to readers: See this post for the true root of the problem, and this post for the solution.
Hi! I have been making a script and I'm completely stumped. I'll start out with the error I'm getting in case it turns out it's actually quite common and someone can point me in the right direction just from this.
The error message:
orts, require, module, __filename, __dirname) { function f(a){throw a;}var j=v
^
Error: Firebase.child failed: First argument must be a non-empty string and can't contain ".", "#", "$", "[", or "]".
at Error (<anonymous>)
at Ha (/home/symbly/www/d20-api-server/node_modules/firebase/lib/firebase-node.js:12:204)
at G.W.H (/home/symbly/www/d20-api-server/node_modules/firebase/lib/firebase-node.js:126:213)
at TrackedObj._doSave (
It kind of seems like it's an error with reporting my actual error though, so I'm not holding out a lot of hope for that.
Here's what I'm trying accomplish:
I want to make an API script that does what this thread describes: https://app.roll20.net/forum/post/705674/cards-tha...
The script should use a page called "Inventory" to track your card objects. When you first make a token from a card, a copy appears on the Inventory page. Any changes that you make to your token are saved to the Inventory version when the token is removed, and when you next bring up that card's token, it loads everything from the Inventory copy.
Here's a breakdown of what's happening instead:
I have discovered that if I restart my script after creating the inventory copy, then everything works. However, if I don't then I consistently get the above error message when I try to take the card back into my hand (ie, upon saving... but after all my code runs). (Note that changes aren't actually saved, either).
(Note: I never got as far as making sure the functions are all called in the right place, so if you're going to be helping me with this, then make sure you always drag the card to your hand first, and only then to the table.)
(Note 2: I have a more complicated version of this script that uses the first line of the GM Notes field instead of the name. It fails in the exact same way.)
Current theories: (I may keep this section updated)
Because restarting the script fixes it, there is an issue with the event binding that is happening when I start the script? ie, the "on" lines?
And/or, because it happens after my save, I am leaving the object in a bad state? But... only if I don't restart the script? I expect that the system is running my code to make the changes, but then failing to actually implement the state change (my changes sure aren't getting saved, even though the code to make the changes all appears to run without error.)
I will include my actual code and the error messages in a different post, to keep this first post as concise as possible.