Protect Your Plant -- Exporting

Well, it finally exports

Posted January 13 2022 10:22am

At one point, I tried exporting Protect Your Plant. The export wouldn't run, and threw up a ton of errors, and I despaired. My code was bad, and at this point, it was huge. I should have been trying to export all along and comparing how it ran compiled to how it ran from the editor so I could find and fix errors as I introduced them. Was it worth trying to fix? The point had just been to make a case for this style of game right?

But it was there, in the back of my mind, that this was all kind of pointless if I couldn't give the files to someone to try easily. This was probably part of the reason for the last hiatus.

So I finally took some time and dug in to why the game hadn't been exporting successfully in the past and what I found wasn't as bad as I expected.

The first problem that I encountered was that most of the game wasn't actually being exported. In fact, the only thing that was getting exported was the top-level menu and global files. We were light about 5/5 gigs of data. I realized that the editor couldn't even see those files from inside the main instance. So I dug around in the files, noticed an old project.godot file hanging around in each from back when level 1 was main, before I ever heard of global variables, or dreamed of changing levels. Turns out the game ignores any directory owned by another project.godot file, which probably explained some of the trouble I had with level changes and instancing previously, and even just getting the editor to recognize that I'd updated a file and reimport it.

Once that was fixed, I discovered that the editor is much more forgiving with paths than the compiled version is. I ran into several flavors of issues here:

  • Path had a // in the wrong place, like res://level1//sprites/plants or something - removed the duplicate slash to fix

  • Path had a capital letter someplace it didn't belong - to fix, had to dig into some .tscn files and manually fix the paths

  • An import file exists but the file has been deleted - to fix deleted the import file

    • an import file exists, original file deleted, but the game still insists it's load bearing and deleting the import causes Bad Things - for these, I just added a 4x4 black png with the same name. Will go back and fix properly sometime in the future. Identify these by the tiny black square.

Eventually I'd worked through all the issues, and moved on to fixing all the error messages I've been ignoring because they didn't outright break the game.

But the important part is, it works. I can compile versions of the game and they even seem to run slightly better than from the engine.