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