mtinfo/init.lua
2021-02-09 19:26:57 +01:00

48 lines
1.3 KiB
Lua

local MP = minetest.get_modpath("mtinfo")
mtinfo = {
basepath = minetest.get_worldpath() .. "/mtinfo"
}
print("[mtinfo] Exporting mtinfo to: " .. mtinfo.basepath)
dofile(MP .. "/common.lua")
dofile(MP .. "/nodes.lua")
dofile(MP .. "/items.lua")
dofile(MP .. "/tools.lua")
dofile(MP .. "/abm.lua")
dofile(MP .. "/lbm.lua")
dofile(MP .. "/recipes.lua")
dofile(MP .. "/textures.lua")
minetest.register_on_mods_loaded(function()
-- workaround for empty translations, defer a globalstep until everything is initialized
minetest.after(0, function()
local start = minetest.get_us_time()
-- copy static assets
minetest.mkdir(mtinfo.basepath)
minetest.mkdir(mtinfo.basepath .. "/data")
-- export data
mtinfo.export_nodes()
mtinfo.export_lbms()
mtinfo.export_abms()
mtinfo.export_items()
mtinfo.export_recipes()
mtinfo.export_tools()
mtinfo.copyrecursive(MP .. "/app/pics", mtinfo.basepath .. "/pics")
mtinfo.copyrecursive(MP .. "/app/js", mtinfo.basepath .. "/js")
mtinfo.copyrecursive(MP .. "/app/css", mtinfo.basepath .. "/css")
mtinfo.copyfile(MP .. "/app/index.html", mtinfo.basepath .. "/index.html")
local diff = minetest.get_us_time() - start
print("[mtinfo] export took " .. diff .. " us")
if minetest.settings:get_bool("mtinfo.autoshutdown") then
minetest.request_shutdown("autoshutdown")
end
end)
end)