ExpiredPopsicle / SnekStudio

Open-source VTuber software using Godot Engine!
GNU General Public License v3.0
128 stars 9 forks source link

Don't try to load mod zips when in-editor #5

Closed exodrifter closed 1 month ago

exodrifter commented 1 month ago

This fixes loading mods both when running from the project and also from a build.

On Linux, if Godot is installed using a package manager, the original code believes that the Mods folder is located at /usr/bin/Mods. This doesn't seem intended, as the project comes with a Mod folder included and exporting the project also creates the Mod folder where the built executable is located.

I would normally just change the filepath to load the Mods folder relative to wherever the project is located by using res://, but I think it would be nice to have a proper path in the logs. So, we also need to use globalize_path to get an absolute path formatted the way a user might expect it for the operating system they are on.

Unfortunately, this function doesn't support exported builds. So, we have to build the path manually for exported builds and I've done it the way the documentation for globalize_path recommends.

ExpiredPopsicle commented 1 month ago

I'm going to have to go over this a little more closely later. The code here is meant to run for builds only, but is running in the editor due to an oversight.

All the _load_mods function does is load packaged .zip files for mods, which are created as part of release exporting. In-editor, they're expected to run as unpackaged directories under res://Mods/.

So a proper fix here is just to make that code not run in the editor at all.

exodrifter commented 1 month ago

@ExpiredPopsicle I've gone ahead and updated _load_mods to not run in the editor at all, as you suggested.