me.fier.engine/mods/main/script/main.lua
2023-08-10 02:10:09 +02:00

37 lines
881 B
Lua

basepath = (debug.getinfo(1, "S").source:sub(2):match("(.*[/\\])") or "./"):sub(1,-2) .. "/../../.." -- Lazy, fix
function main()
dofile(basepath .. "/mods/main/script/game.lua")
end
xpcall(main,function(err)
local function splitString(str,sep)
if sep == nil then
sep = "%s"
end
local t={}
for strs in string.gmatch(str, "([^"..sep.."]+)") do
table.insert(t, strs)
end
return t
end
local function joinString(t,sep)
local str = t[1]
local index = 2
local length = #t
while index < length do
str = str .. sep .. t[index]
index = index + 1
end
return str
end
local debugString = splitString(debug.traceback(),"\n")
debugString[#debugString] = nil
debugString[#debugString] = nil
debugString[#debugString] = nil
table.remove(debugString,2)
print("\n--- ERROR ---\n" .. err .. "\n\n" .. joinString(debugString,"\n"))
os.exit(1)
end)