Bundle error: Unknown source (Access is denied)

#21

“custom” resources are stored like the other game assets, inside the internal archive (game.darc).
“bundle” resources are store “next to” the app executable, and cannot be loaded using sys.load_resource()

2 Likes

#22

So basically I was having the exact problem discussed here. Using sys.load_resource() and loadstring() seems to be doing the trick (completely disregarding require). Like this:

map_info = sys.load_resource(map_path)
map_info = assert(loadstring(map_info))()

map_path looks something like this:

local map_path = "/" .. string.gsub(map_dictionary.map_info[hashed_level].script_require, "%.", "/") .. ".lua"

Map dictionary:

M.map_info[hash("h_potion_hut")] = {script_require = "maps.map_codes.h_potion_hut", [other stuff]}

This was just for testing purposes so if I go down this route then I may as well drop the string replacements etc and just have the path stored as “/maps/map_codes/h_potion_hut.lua” in the map dictionary.

So, uh… I guess this just entirely sidesteps the issue? Is using sys.load_resource() and loadstring() like this going to hit me with any unintended consequences? Maybe it would take a bit longer to load but I’m not noticing anything when testing. The docs for load_resource say the contents are just loaded as a string, so since I replace the map data whenever I load, I shouldn’t be accumulating a bunch of data in memory, right?

0 Likes

#23

I created an example of a few ways to load Lua code here:

1 Like