mod-skeleton/init.lua

57 lines
966 B
Lua
Raw Normal View History

2021-05-23 06:49:52 -07:00
2021-08-12 23:10:12 -07:00
skeleton = {}
skeleton.modname = core.get_current_modname()
skeleton.modpath = core.get_modpath(skeleton.modname)
2021-05-23 06:49:52 -07:00
function skeleton.log(lvl, msg)
if not msg then
msg = lvl
lvl = nil
end
msg = "[" .. skeleton.modname .. "] " .. msg
if not lvl then
core.log(msg)
else
core.log(lvl, msg)
end
end
-- support mob libraries in order of preference
local mob_libs = {
2021-08-12 21:52:15 -07:00
"mobs",
"cmer",
"creatures",
}
for _, ml in ipairs(mob_libs) do
if core.get_modpath(ml) then
2021-08-12 23:10:12 -07:00
skeleton.lib = ml
break
end
end
-- check for compatible library
2021-08-12 23:10:12 -07:00
if not skeleton.lib then
skeleton.log("error", "Could not load. A compatible mob library was not found. Please install one of the following: "
.. table.concat(mob_libs, ", "))
skeleton = nil
do return end
end
2021-08-12 23:10:12 -07:00
if skeleton.lib == "creatures" then
skeleton.lib = "cmer"
end
2021-05-23 06:49:52 -07:00
local scripts = {
"settings",
"entity",
}
for _, script in ipairs(scripts) do
2021-08-12 23:10:12 -07:00
dofile(skeleton.modpath .. "/" .. script .. ".lua")
2021-05-23 06:49:52 -07:00
end