I have a data file at cache/warp512.dat, which opens fine if I am in debug mode, but when I try packing it with my game file, the compiler throws an error:
file not found
fatal error:
An runtime error or other unhandled exception was thrown during
pre-initialization.
Here’s the preinit code that calls for the resource:
// Read the 512-table caches from resource file
local extTables = File.openRawResource('cache/warp512.dat');
local bothLists = extTables.unpackBytes('l1022');
extTables.close();
I have read the docs on any related subject twice now, and have tried a lot, including:
Renaming the folder (tablecache/warp512.dat)
Renaming the file (cache/warp.dat)
Giving it different extensions, in case bundling resources filters by extension:
.txt
.bmp
no extension
Using a file alias: cache/warp512.dat=warp512table
t3make -clean followed by t3make -a
I keep getting this error. Again, I can confirm that in debug mode, every opens, and the file contents are correct. This is just when preinit happens outside of debug mode.
Any help is greatly appreciated. I don’t know what else to do.
Well, resources don’t actually get packed into the game file until after Preinit is done. But according to the docs it shouldn’t really matter (it should just load the original files from disk). I couldn’t find any info about file safety levels in the compiler that might be interfering during preinit…
Where does the compiler create the .t3 file, and what is your current working directory when you invoke it? Are they both the same directory that has cache in it?
Because if I am just loading this file to write its contents into a Vectorfor preinit caching, then I guess I don’t really need to bundle the file with the game, do I…? …I, uh, had not considered this…
People on this forum are amazing.
Yup! gameMain.t, gameMain.t3, and cache/ are in the same directory!
(Though, after your previous point, this might not relevant anymore lol)
Why are you packing the file into the t3 file if you’re reading it during preinit anyway? You’re including an unneeded file with the t3. The file is not needed anymore when shipping the game since you’ve already read it in preinit.