mtinfo/init.lua

62 lines
1.8 KiB
Lua
Raw Normal View History

2020-01-06 14:12:37 +01:00
local MP = minetest.get_modpath("mtinfo")
2021-06-02 14:25:36 +02:00
local mtinfo_enabled = minetest.settings:get_bool("mtinfo.enabled")
local autoshutdown = minetest.settings:get_bool("mtinfo.autoshutdown")
if not mtinfo_enabled then
-- skip everything
return
end
2020-01-06 13:31:18 +01:00
mtinfo = {
2021-03-10 08:26:32 +01:00
basepath = minetest.get_worldpath() .. "/mtinfo",
settings = {
startpage_mod = minetest.settings:get("mtinfo.startpage_mod"),
screenshot_mod = minetest.settings:get("mtinfo.screenshot_mod"),
screenshot_name = minetest.settings:get("mtinf.screenshot_name")
}
2019-08-23 09:13:04 +02:00
}
2020-01-06 14:12:37 +01:00
print("[mtinfo] Exporting mtinfo to: " .. mtinfo.basepath)
2020-01-06 13:31:18 +01:00
dofile(MP .. "/common.lua")
dofile(MP .. "/items.lua")
dofile(MP .. "/abm.lua")
dofile(MP .. "/lbm.lua")
dofile(MP .. "/recipes.lua")
dofile(MP .. "/textures.lua")
2020-01-06 14:29:14 +01:00
2021-01-16 21:03:43 +01:00
minetest.register_on_mods_loaded(function()
-- workaround for empty translations, defer a globalstep until everything is initialized
2021-03-03 17:47:02 +01:00
-- deferred by 1 second until technic.recipes is populated
minetest.after(1, function()
2021-01-16 21:03:43 +01:00
local start = minetest.get_us_time()
2021-02-09 19:26:57 +01:00
-- copy static assets
minetest.mkdir(mtinfo.basepath)
minetest.mkdir(mtinfo.basepath .. "/data")
2021-01-16 21:03:43 +01:00
-- export data
mtinfo.export_lbms()
mtinfo.export_abms()
mtinfo.export_items()
mtinfo.export_recipes()
2021-02-10 07:54:51 +01:00
-- export textures
mtinfo.export_textures()
2021-01-16 21:03:43 +01:00
mtinfo.copyrecursive(MP .. "/app/pics", mtinfo.basepath .. "/pics")
mtinfo.copyrecursive(MP .. "/app/js", mtinfo.basepath .. "/js")
mtinfo.copyrecursive(MP .. "/app/css", mtinfo.basepath .. "/css")
2021-02-10 07:09:28 +01:00
mtinfo.copyrecursive(MP .. "/app/webfonts", mtinfo.basepath .. "/webfonts")
2021-01-16 21:03:43 +01:00
mtinfo.copyfile(MP .. "/app/index.html", mtinfo.basepath .. "/index.html")
local diff = minetest.get_us_time() - start
print("[mtinfo] export took " .. diff .. " us")
2021-02-09 19:26:57 +01:00
2021-06-02 14:25:36 +02:00
if autoshutdown then
2021-02-09 19:26:57 +01:00
minetest.request_shutdown("autoshutdown")
end
2021-01-16 21:03:43 +01:00
end)
end)