diff --git a/inventoryManager.lua b/inventoryManager.lua index 67b227c..4cb2ef7 100644 --- a/inventoryManager.lua +++ b/inventoryManager.lua @@ -15,6 +15,17 @@ local _baseDir = fs.getDir(shell.getRunningProgram()) local function _path(rel) return fs.combine(_baseDir, rel) end +-- Write crash info to a file so we can always read it +local function _crashLog(err) + local f = fs.open(_path(".crash.log"), "w") + if f then + f.write(tostring(err) .. "\n" .. (debug and debug.traceback and debug.traceback() or "")) + f.close() + end +end + +local ok, err = xpcall(function() + -- Override dofile to load modules into our _ENV so they inherit -- Opus's require/package (CC:Tweaked dofile uses _G instead). local _ccDofile = dofile @@ -685,9 +696,16 @@ local function main() ) end -local ok, err = pcall(main) +main() + +end, function(e) return tostring(e) .. "\n" .. debug.traceback() end) + if not ok then + _crashLog(err) printError(tostring(err)) + print("") + print("Crash log saved to: " .. _path(".crash.log")) + print("") print("Press any key to exit...") - os.pullEvent("key") + os.pullEvent("char") end \ No newline at end of file