xban2/dbimport.lua

39 lines
1021 B
Lua
Raw Normal View History

xban.importers = { }
dofile(xban.MP.."/importers/minetest.lua")
dofile(xban.MP.."/importers/v1.lua")
2014-06-26 08:17:40 +02:00
dofile(xban.MP.."/importers/v2.lua")
minetest.register_chatcommand("xban_dbi", {
description = "Import old databases",
params = "<importer>",
privs = { server=true },
func = function(name, params)
if params == "--list" then
2017-02-17 06:30:30 +01:00
local importers = { }
for importer in pairs(xban.importers) do
table.insert(importers, importer)
end
minetest.chat_send_player(name,
("[xban] Known importers: %s"):format(
2017-02-17 06:30:30 +01:00
table.concat(importers, ", ")))
return
elseif not xban.importers[params] then
minetest.chat_send_player(name,
("[xban] Unknown importer `%s'"):format(params))
minetest.chat_send_player(name, "[xban] Try `--list'")
return
end
local f = xban.importers[params]
local ok, err = f()
if ok then
minetest.chat_send_player(name,
"[xban] Import successfull")
else
minetest.chat_send_player(name,
("[xban] Import failed: %s"):format(err))
end
end,
})