How do I make sure my exported game has access to --export-pck?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By anastasie

I’m working on an application that needs to be able to generate PCKs on the fly. I’m calling the application via something like this in GDScript:

OS.execute(OS.get_executable_path(), ["--export-pck", etc, etc])

This works in the editor preview, but if I try to export the project (for MacOS in my case), and I try to do ./path/to/my/export --help, it doesn’t list --export-pck as a valid command line switch. I’m exporting from a tools-enabled 3.3.2 build of Godot. Do I need to do something else in addition?

:bust_in_silhouette: Reply From: Mario

Your problem here is the fact that the default export template doesn’t include the tools portion (i.e. editor-only features like the pck export command line option) and it’s not needed at all. Your snippet works in the editor, since that’s using the full editor executable for obvious reasons.

Rather than calling your own program with command line parameters, you should instead use PCKPacker in GDScript:

var packer = PCKPacker.new()
packer.pck_start("my-export.pck")
packer.add_file("res://first.txt", "second.txt")
packer.flush()

Thanks! I didn’t find a reference to this class in the PCK documentation. Does this mean I don’t actually need a tools-enabled build at all if I just use this class and ProjectSettings.load_resource_pack?

anastasie | 2021-07-18 08:11

You don’t need any special build for this to work. “tools enabled” only means it’s a full build for/of the Godot Editor, not just the runtime (i.e. export template).

Mario | 2021-07-18 14:56