Luanti: minetest -> core
This commit is contained in:
parent
0f514312ad
commit
189dc8bdb6
@ -2,7 +2,6 @@ read_globals = {
|
|||||||
"DIR_DELIM",
|
"DIR_DELIM",
|
||||||
"INIT",
|
"INIT",
|
||||||
|
|
||||||
"minetest",
|
|
||||||
"core",
|
"core",
|
||||||
"dump",
|
"dump",
|
||||||
"dump2",
|
"dump2",
|
||||||
|
@ -65,19 +65,19 @@ unified_money.register_backend({
|
|||||||
})
|
})
|
||||||
|
|
||||||
-- Warning functions
|
-- Warning functions
|
||||||
minetest.register_on_mods_loaded(function()
|
core.register_on_mods_loaded(function()
|
||||||
minetest.log("warning",
|
core.log("warning",
|
||||||
"[um_backend_dummy] You are using the dummy backend of Unified Money. NO CHANGES WILL BE SAVED ON DISK!")
|
"[um_backend_dummy] You are using the dummy backend of Unified Money. NO CHANGES WILL BE SAVED ON DISK!")
|
||||||
minetest.log("warning",
|
core.log("warning",
|
||||||
"[um_backend_dummy] If you want to save currency data over restarts, " ..
|
"[um_backend_dummy] If you want to save currency data over restarts, " ..
|
||||||
"use another backend such as um_backend_plain.")
|
"use another backend such as um_backend_plain.")
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local orange = minetest.get_color_escape_sequence("orange")
|
local orange = core.get_color_escape_sequence("orange")
|
||||||
minetest.register_on_joinplayer(function(ObjectRef)
|
core.register_on_joinplayer(function(ObjectRef)
|
||||||
local name = ObjectRef:get_player_name()
|
local name = ObjectRef:get_player_name()
|
||||||
minetest.chat_send_player(name,
|
core.chat_send_player(name,
|
||||||
orange .. "The dummy backend of Unified Money is used. NO CHANGES WILL BE SAVED ON DISK!")
|
orange .. "The dummy backend of Unified Money is used. NO CHANGES WILL BE SAVED ON DISK!")
|
||||||
minetest.chat_send_player(name,
|
core.chat_send_player(name,
|
||||||
orange .. "If you want to save currency data over restarts, use another backend such as um_backend_plain.")
|
orange .. "If you want to save currency data over restarts, use another backend such as um_backend_plain.")
|
||||||
end)
|
end)
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
USA
|
USA
|
||||||
]]
|
]]
|
||||||
|
|
||||||
local WP = minetest.get_worldpath()
|
local WP = core.get_worldpath()
|
||||||
local SAVEFILE = WP .. "/um_backend_plain.lua"
|
local SAVEFILE = WP .. "/um_backend_plain.lua"
|
||||||
|
|
||||||
local savefile_fd = io.open(SAVEFILE, "r")
|
local savefile_fd = io.open(SAVEFILE, "r")
|
||||||
@ -28,20 +28,20 @@ else
|
|||||||
local savefile_txt = savefile_fd:read("*a")
|
local savefile_txt = savefile_fd:read("*a")
|
||||||
savefile_fd:close()
|
savefile_fd:close()
|
||||||
savefile_fd = nil -- luacheck: no unused
|
savefile_fd = nil -- luacheck: no unused
|
||||||
database = minetest.deserialize(savefile_txt) or {}
|
database = core.deserialize(savefile_txt) or {}
|
||||||
end
|
end
|
||||||
|
|
||||||
local function save()
|
local function save()
|
||||||
minetest.log("action", "[um_backend_plain] Saving file")
|
core.log("action", "[um_backend_plain] Saving file")
|
||||||
minetest.safe_file_write(SAVEFILE, minetest.serialize(database))
|
core.safe_file_write(SAVEFILE, core.serialize(database))
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.after(30, function()
|
core.after(30, function()
|
||||||
save()
|
save()
|
||||||
minetest.after(60, save)
|
core.after(60, save)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
minetest.register_on_shutdown(save)
|
core.register_on_shutdown(save)
|
||||||
|
|
||||||
-- All functions return boolean indicating success unless otherwise specified
|
-- All functions return boolean indicating success unless otherwise specified
|
||||||
unified_money.register_backend({
|
unified_money.register_backend({
|
||||||
|
@ -18,11 +18,11 @@
|
|||||||
]]
|
]]
|
||||||
|
|
||||||
unified_money = {}
|
unified_money = {}
|
||||||
local getmod = minetest.get_current_modname
|
local getmod = core.get_current_modname
|
||||||
local str = tostring
|
local str = tostring
|
||||||
|
|
||||||
local function log(lvl, msg)
|
local function log(lvl, msg)
|
||||||
return minetest.log(lvl, "[um_core] " .. msg)
|
return core.log(lvl, "[um_core] " .. msg)
|
||||||
end
|
end
|
||||||
|
|
||||||
function unified_money.register_backend(backend)
|
function unified_money.register_backend(backend)
|
||||||
@ -51,7 +51,7 @@ local function log_on_success(status, lvl, msg)
|
|||||||
return status
|
return status
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_on_mods_loaded(function()
|
core.register_on_mods_loaded(function()
|
||||||
if not unified_money.backend then
|
if not unified_money.backend then
|
||||||
error("Please load ONE Unified Money backend.")
|
error("Please load ONE Unified Money backend.")
|
||||||
end
|
end
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
USA
|
USA
|
||||||
]]
|
]]
|
||||||
|
|
||||||
local S = minetest.get_translator("um_dump_data")
|
local S = core.get_translator("um_dump_data")
|
||||||
|
|
||||||
local function get_dump_table()
|
local function get_dump_table()
|
||||||
local dump_table = {}
|
local dump_table = {}
|
||||||
@ -27,8 +27,8 @@ local function get_dump_table()
|
|||||||
return dump_table
|
return dump_table
|
||||||
end
|
end
|
||||||
|
|
||||||
local WP = minetest.get_worldpath()
|
local WP = core.get_worldpath()
|
||||||
minetest.register_chatcommand("um_dump_data", {
|
core.register_chatcommand("um_dump_data", {
|
||||||
description = S("Dump all data of the current backend to a um_backend_plain-compactibible file"),
|
description = S("Dump all data of the current backend to a um_backend_plain-compactibible file"),
|
||||||
param = S("<path, relative to world directory>"),
|
param = S("<path, relative to world directory>"),
|
||||||
privs = { server = true },
|
privs = { server = true },
|
||||||
@ -39,9 +39,9 @@ minetest.register_chatcommand("um_dump_data", {
|
|||||||
end
|
end
|
||||||
|
|
||||||
local dump_table = get_dump_table()
|
local dump_table = get_dump_table()
|
||||||
local serialized = minetest.serialize(dump_table)
|
local serialized = core.serialize(dump_table)
|
||||||
local path = WP .. DIR_DELIM .. param
|
local path = WP .. DIR_DELIM .. param
|
||||||
minetest.safe_file_write(path, serialized)
|
core.safe_file_write(path, serialized)
|
||||||
return true, S("Data dumped to @1", path)
|
return true, S("Data dumped to @1", path)
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
USA
|
USA
|
||||||
]]
|
]]
|
||||||
|
|
||||||
local S = minetest.get_translator("um_frontend_cmd")
|
local S = core.get_translator("um_frontend_cmd")
|
||||||
local _utc = um_translate_common
|
local _utc = um_translate_common
|
||||||
|
|
||||||
local cmd = chatcmdbuilder.register("um", {
|
local cmd = chatcmdbuilder.register("um", {
|
||||||
|
@ -17,17 +17,17 @@
|
|||||||
USA
|
USA
|
||||||
]]
|
]]
|
||||||
|
|
||||||
if minetest.get_modpath("um_backend_plain") then
|
if core.get_modpath("um_backend_plain") then
|
||||||
error("[um_migrate_plain] This mod conflicts with um_backend_plain. Please install another backend.")
|
error("[um_migrate_plain] This mod conflicts with um_backend_plain. Please install another backend.")
|
||||||
end
|
end
|
||||||
|
|
||||||
local S = minetest.get_translator("um_migrate_plain")
|
local S = core.get_translator("um_migrate_plain")
|
||||||
|
|
||||||
minetest.register_chatcommand("um_migrate_plain", {
|
core.register_chatcommand("um_migrate_plain", {
|
||||||
description = S("Reads data of um_backend_plain and write it into the currently active backend."),
|
description = S("Reads data of um_backend_plain and write it into the currently active backend."),
|
||||||
privs = { server = true },
|
privs = { server = true },
|
||||||
func = function()
|
func = function()
|
||||||
local f = io.open(minetest.get_worldpath() .. "/um_backend_plain.lua", "r")
|
local f = io.open(core.get_worldpath() .. "/um_backend_plain.lua", "r")
|
||||||
if not f then
|
if not f then
|
||||||
return false, S("um_backend_plain savefile not found.")
|
return false, S("um_backend_plain savefile not found.")
|
||||||
end
|
end
|
||||||
@ -37,7 +37,7 @@ minetest.register_chatcommand("um_migrate_plain", {
|
|||||||
f = nil -- luacheck: no unused
|
f = nil -- luacheck: no unused
|
||||||
|
|
||||||
local i = 0
|
local i = 0
|
||||||
local db = minetest.deserialize(f_txt)
|
local db = core.deserialize(f_txt)
|
||||||
for name, balance in pairs(db) do
|
for name, balance in pairs(db) do
|
||||||
i = i + 1
|
i = i + 1
|
||||||
unified_money.set_balance(name, balance, true)
|
unified_money.set_balance(name, balance, true)
|
||||||
|
@ -19,14 +19,14 @@
|
|||||||
|
|
||||||
-- We use on_joinplayer to regenerate (somehow accidentally) deleted accounts
|
-- We use on_joinplayer to regenerate (somehow accidentally) deleted accounts
|
||||||
|
|
||||||
minetest.register_on_joinplayer(function(ObjectRef)
|
core.register_on_joinplayer(function(ObjectRef)
|
||||||
local name = ObjectRef:get_player_name()
|
local name = ObjectRef:get_player_name()
|
||||||
unified_money.ensure_exists(name)
|
unified_money.ensure_exists(name)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
do
|
do
|
||||||
local old_remove_player = minetest.remove_player
|
local old_remove_player = core.remove_player
|
||||||
function minetest.remove_player(name) -- luacheck: ignore 122
|
function core.remove_player(name) -- luacheck: ignore 122
|
||||||
local status = old_remove_player(name)
|
local status = old_remove_player(name)
|
||||||
if status == 0 then
|
if status == 0 then
|
||||||
unified_money.delete_account(name)
|
unified_money.delete_account(name)
|
||||||
|
@ -18,8 +18,8 @@
|
|||||||
]]
|
]]
|
||||||
|
|
||||||
local S
|
local S
|
||||||
if minetest.get_translator then
|
if core.get_translator then
|
||||||
S = minetest.get_translator("um_translate_common")
|
S = core.get_translator("um_translate_common")
|
||||||
else
|
else
|
||||||
-- Extract of the simple skins mod, MIT License text at root/LICENSE.simple_skins
|
-- Extract of the simple skins mod, MIT License text at root/LICENSE.simple_skins
|
||||||
S = function(str, ...)
|
S = function(str, ...)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user