Hey Folks! More work on the loader today. As you can see from today's screenshot :)

It's coming along, but not without some expected speed bumps. I wasted a good hour or two on LitJson again, debugging its cryptic error messages. In the end, it turned out I had two issues.

First, my last names data was a different structure than the rest of my data (flat array vs. the more common dictionary of objects), and LitJson didn't like that. I ended up changing the data format to a simple comma-separated-variables (csv) text file. So now we can load those (which might be handy in the future for other simple data types).

My second issue was that my save game file lacked a "name" field, which all other data types had. It took me way too long to figure this out. Again, the error was cryptic. But once I did, the file loaded and parsed into an object, and we were off to converting that into a game scene!

(Side note: I'm starting to seriously consider adding some sort of json validator tool at this point. The sheer number of hours I've wasted debugging typos and issues in json files is unacceptable, and this would also help eventual modders.)

In-game during the load process, the usual suspects started appearing. Null pointers for things I forgot to initialize, data I forgot to apply, etc.

But the latest, and biggest, problem I have to tackle is orphaned objects. Again, this is predictable. But I thought I had taken care of this.

As it turns out, I was storing things in-game by their name, and not by their unique ID. So the game wasn't able to look-up items by ID when piecing everything back together. I think this will be simple to fix in principle, but in practice, will likely involve a fair bit of work. Basically, I'll have to refactor in-game look-up functions to use IDs in a bunch of places. But I'll also need it to be sensitive to the fact that sometimes I'll want new unique IDs for items that are copies of an original.

Again, doable, but might have a few tricky spots. That's tomorrow!