How to load multiple pck files for the purpose of patching/mods/dlc?

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

Hello,

I have an issue with load_resource_pack() not working as expected, and not much documentation or tutorials to help. I’ll explain what’s happening:

Lets say I have a project with 4 folders inside res://
I want to export the main project with folders 1, 2, and 3 with all it’s dependencies. This works fine, and generates the .exe and .pck.

Next I want to export just folder 4 in a .pck file, into the same directory as the initial export above. This works fine. I now have one .exe and two .pck files.

On launch of .exe, from inside the main project, my code runs load_resource_pack() to unpack folder 4 inside res://

However the issue is that immediately before the unpack, my res:// file structure is OK, but immediately after the unpack, my entire res:// folder is seemingly replaced with the contents of folder 4 and it’s dependencies, and trashes the bulk of the project. None of my 4 folder paths are named the same, but I set “replace_files” to false just in case, and it still replaces everything with just folder 4.

Is there an easy/clear way to load post release patches into a game? B/c this doesn’t seem to work right, or I’m not understanding something.

Thank you

:bust_in_silhouette: Reply From: ryanrom5

So I figured out my problem.

First, the problem I explained above with load_resource_pack() replacing the entire folder structure with the pck contents only happens in EDITOR when I put the pck file in the project folder and unpack there.
I later made an in-game debug console and printed the project’s file contents inside an exported version of the project, and the extra pck file was opened and ADDED not replaced to the projects file structure. It turns out this behavior wasn’t my problem at all, because it was working under the hood in the exported version the whole time.

My original issue was that my test resource inside the pck file wasn’t loading in the game properly. It was silently failing. I had assumed, b/c of my test above, that it was messing with my file structure even though it wasn’t. So on a whim, I updated the reference location to the png image (by drag/drop), and all of a sudden it works. I’m really trying to resist the urge to not slam my head on my desk …lol

In conclusion, if you want to do patching/modding/dlc or just split your project into multiple pck files, you can just export a pck with the contents you want to add to your project later, and in the main project load them in. BUT watch out for doing this in editor for reasons mentioned above. Idk how you would debug any issues in the editor for your patches, if any arise.