me.fier.engine/mods/main/script/main.lua

37 lines
881 B
Lua
Raw Normal View History

2023-08-10 00:10:09 +00:00
basepath = (debug.getinfo(1, "S").source:sub(2):match("(.*[/\\])") or "./"):sub(1,-2) .. "/../../.." -- Lazy, fix
2023-05-16 10:29:12 +00:00
2023-08-10 00:10:09 +00:00
function main()
dofile(basepath .. "/mods/main/script/game.lua")
2023-05-16 10:29:12 +00:00
end
2023-08-10 00:10:09 +00:00
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
2023-05-16 10:29:12 +00:00
end
2023-08-10 00:10:09 +00:00
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
2023-05-16 10:29:12 +00:00
end
2023-08-10 00:10:09 +00:00
return str
2023-05-16 10:29:12 +00:00
end
2023-08-10 00:10:09 +00:00
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)