Skip to content

Add runtime file registration APIs for GPK and PKG assets#27

Open
Enderclem0 wants to merge 1 commit intoSGG-Modding:masterfrom
Enderclem0:feature/add-granny-file-api
Open

Add runtime file registration APIs for GPK and PKG assets#27
Enderclem0 wants to merge 1 commit intoSGG-Modding:masterfrom
Enderclem0:feature/add-granny-file-api

Conversation

@Enderclem0
Copy link
Copy Markdown

@Enderclem0 Enderclem0 commented Apr 7, 2026

Adds two new Lua API functions to the rom.data table:

  • rom.data.add_granny_file(filename, full_path) registers a GPK file for file-redirection
  • rom.data.add_package_file(filename, full_path) registers a PKG/PKG_MANIFEST file for file-redirection

These insert into the existing additional_granny_files / additional_package_files maps that are currently only populated during the DLL init scan of plugins_data/.
This allows for mod to generate gpk files at runtime and not require a game restart to be picked up by h2m (for exemple https://github.com/Enderclem0/CG3H)

os.execute('my_builder.exe --build')
rom.data.add_granny_file("Melinoe.gpk", "C:/path/to/built/Melinoe.gpk")

Changes

  • data.cpp: Added extern declarations for the two maps from main.cpp, two new static functions, and their Lua bindings
  • No changes to main.cpp

Allows mods to register custom GPK/PKG files for file-redirection
at runtime, after the initial plugins_data scan has completed.

This enables mods that generate assets during Lua plugin init
(before LoadAllModelAndAnimationData runs) to have those assets
picked up by the game's normal loading path without requiring
a restart.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants