[LUA] Add custom Lua require loader to resolve modules via the engine file system. - #2121
Open
Neloreck wants to merge 1 commit into
Open
[LUA] Add custom Lua require loader to resolve modules via the engine file system.#2121Neloreck wants to merge 1 commit into
require loader to resolve modules via the engine file system.#2121Neloreck wants to merge 1 commit into
Conversation
…esystem, supporting archived and loose files.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Notes
package.pathand could only resolve loose files — scripts packed inside game archives were not visible torequire.package.loaders[2]: afterpackage.preload, before the defaultpackage.pathloader. On a miss it returns a candidate-path message string instead of raising, so the remaining loaders still run andrequireerror output stays informative.gamedatafiles override archived ones (archives are registered first duringfsgame.ltxscan, and later registrations win), consistently with how every other game asset is resolved.@<resolved path>, so script stack traces point to real file paths.Changes
gamedata_module_loader— apackage.loadersentry that mapsrequire("scripts.folder.file")togamedata\scripts\folder\file.scriptand loads it viaFS.r_open/luaL_loadbuffer, supporting both loose and archived files.setup_gamedata_module_loading, grouping loader registration and the existingpackage.pathgamedata append into a single setup step.package.pathblock inCScriptEngine::initwith asetup_gamedata_module_loadingcall.