Managing and creating PCX files to segment game

Godot Version

4.3-stable

Question

I’m feeling a little lost. I’ve been trying to export sub-parts of my game into separate PCX files (or whatever… zip?). The basic idea is simple enough; I’m looking to achieve something like:

  • Root
    • Data/
      • core.pcx
      • level1.pcx
      • level2.pcx
      • (and over time, patches and/or DLCs go here)
  • MyGame.exe

There are several reasons for this. Obvious one being a DLC, but I also want to be able to make updates to segments of the game without having to redistribute ALL of the game packages.

Idea is, I would dynamically load up all these PCX files as the game starts and (optionally, as an example) load up TSCN files inside them and append these into my main “game scene tree” where appropriate. I think - probably - I could get this working.

What fails me is how to go about creating these packages in the first place.

Simple form, I’m going to Project Export, selecting my Data/Core folder for export and press “Export PCK/ZIP”. It generates me a .zip file but when I open THAT up - I seem to get my entire game folder structure, including all .tscn files elsewhere in the project.

Project Export

Final ZIP archive

My GUESS is, this has something to do with the Export Mode saying (and dependencies) and that somehow pulls in a lot of stuff. But I can’t find a way to force it to just ignore that; “it’ll be fine, trust me” kind of thing :smiley:

So I guess my question is twofold. 1. Am I missing something? or 2. Am I heading down an entirely wrong path and I should go about this in a different way?

Any insights will be much appreciated.

PS: The Godot pack file format is PCK, not PCX which is a legacy image format (not supported by Godot).

Right ok. Well the format itself isn’t really what bothers me at this time, but thank you :smiley:

The default export will throw all dependency into the PCK files no matter your resource or folder selection. So you get a billion duplicated file copies if you have multiple PCK files, e.g. every PCK will have your autoload scripts or a copy of the same default texture that everything uses.

Dont use the default export if you have more than a single PCK file else you have bloated PCK files. Instead, Create an EditorExportPlugin. That allows you to hook into the export project process, look at the currently exported template name, and reject all the files from _export_file() that do not fit.

E.g. by looking at the filepath or some other meta, e.g. if “/dlc01” is in filepath and export template name is “DLC01” allow the file in, else reject. If you need even more detailed granularity you can create an export file list in your projectsettings for the templates with scripts.

1 Like

Thank you :smiley: This takes me a good step along the way.

Just to test things out, I made a simple plugin as you suggested. And it does indeed work.

extends EditorExportPlugin

func _export_file(path: String, type: String, features: PackedStringArray) -> void:
	if not "data/core/tutorials" in path:
		skip()

Now I wouldn’t be THIS granular and package up the tutorials alone. But it serves to test things.

You lost me however, with “you can create an export file list in your projectsettings for the templates with scripts”. While the solution I now have currently works, it’s not really practical in that the path and exclusion filter is hardcoded. And I would need a complete rebuild to ideally output a series of PCK files.

I’m fine if it ends up needing to be built from command line with a series of build/exports - but I don’t really see a way to send in a parameter to this filter I now have in place. I’m hoping this is what you hinted at? :smiley: Sorry, this aspect of Godot is still a bit of a mystery to me.

You dont need to hardcode your filter in the plugin. Read a config file in at the start of the export begin to make the plugin filter configurable.

When you create an export template with a specific file filter you will notice this is all stored in the project file in your project folder, so you can write that part manually inside this file with a script instead of using a plugin. If the plugin does what you need it is way easier to work with the plugin.

1 Like

Right ok. I think I need to have a bit more of a think :smiley: I see what you mean though, everything does seem to be in export_presets.cfg. I also experimented with custom options for my new plugin and I do - sort of - see a path forward.

Thanks for pointing me in the right direction :smiley: