I am trying to save an inventory object to a firestore field and then read it back into the inventory object. The save “seems” to work but the load does not work. Here is my test code to explain:
Step1: Add item to inventory and save it to firestore field:
Why does step 3 fail? It has something to do with storing the inventory in a firestore field as a json. If I remove the firestore functionality and simply load and save the inventory to a scene variable it works. But I need to store the inventory in firebase so that if the user uses different devices they still have their inventory available to them.
I have 0 experience with Firebase. It would help if the load and save events used different variables. The last value of variable “svRocketInventory” is a string. At that point it should be a structure. Because both sections use the same variable, it’s tough to tell which section set it. I’m guessing it was the save section.
Either the load event isn’t being triggered or the value isn’t being retrieved or at least retrieved in a tenth of a second. Is there a more foolproof way of checking if a value is returned from the Firestore?
I would try using a different variable in the save and load events.
Looks good as far as I can tell. Try as Keith hinted at and use the variable that is “store the result state” svServerStatusCode to make sure the value has been returned from Firestore. Then in a separate condition, check that the call back ok (or whatever it sends on success) has been sent to the variable. If so, then parse your svRocketInv into svRocketInv and store into RocketInventory. If it got an error, make arrangements for that too.