mirror of
https://github.com/minetest-mods/maptools.git
synced 2024-12-24 00:10:21 +01:00
Update intllib support to avoid using deprecated functions
This commit is contained in:
parent
8bb6f0fece
commit
199180ee80
@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Changed
|
||||
|
||||
- Update intllib support to avoid using deprecated functions.
|
||||
|
||||
## 1.0.0 - 2017-02-19
|
||||
|
||||
- Initial versioned release.
|
||||
|
@ -5,7 +5,7 @@ Copyright © 2012-2019 Hugo Locurcio and contributors.
|
||||
Licensed under the zlib license. See LICENSE.md for more information.
|
||||
--]]
|
||||
|
||||
local S = maptools.intllib
|
||||
local S = maptools.S
|
||||
|
||||
maptools.creative = maptools.config["hide_from_creative_inventory"]
|
||||
|
||||
|
@ -5,7 +5,7 @@ Copyright © 2012-2019 Hugo Locurcio and contributors.
|
||||
Licensed under the zlib license. See LICENSE.md for more information.
|
||||
--]]
|
||||
|
||||
local S = maptools.intllib
|
||||
local S = maptools.S
|
||||
|
||||
maptools.creative = maptools.config["hide_from_creative_inventory"]
|
||||
|
||||
|
20
init.lua
20
init.lua
@ -10,20 +10,11 @@ Licensed under the zlib license. See LICENSE.md for more information.
|
||||
|
||||
maptools = {}
|
||||
|
||||
local S
|
||||
if minetest.get_modpath("intllib") then
|
||||
S = intllib.Getter()
|
||||
else
|
||||
S = function(s) return s end
|
||||
end
|
||||
maptools.intllib = S
|
||||
|
||||
local modpath = minetest.get_modpath("maptools")
|
||||
|
||||
maptools.drop_msg = function(itemstack, player)
|
||||
local name = player:get_player_name()
|
||||
minetest.chat_send_player(name, S("[maptools] tools/nodes do not drop!"))
|
||||
end
|
||||
local S, NS = dofile(modpath .. "/intllib.lua")
|
||||
maptools.S = S
|
||||
maptools.NS = NS
|
||||
|
||||
dofile(modpath .. "/config.lua")
|
||||
dofile(modpath .. "/aliases.lua")
|
||||
@ -32,6 +23,11 @@ dofile(modpath .. "/default_nodes.lua")
|
||||
dofile(modpath .. "/nodes.lua")
|
||||
dofile(modpath .. "/tools.lua")
|
||||
|
||||
maptools.drop_msg = function(itemstack, player)
|
||||
local name = player:get_player_name()
|
||||
minetest.chat_send_player(name, S("[maptools] tools/nodes do not drop!"))
|
||||
end
|
||||
|
||||
if minetest.setting_getbool("log_mods") then
|
||||
minetest.log("action", S("[maptools] loaded."))
|
||||
end
|
||||
|
44
intllib.lua
Normal file
44
intllib.lua
Normal file
@ -0,0 +1,44 @@
|
||||
-- Fallback functions for when `intllib` is not installed.
|
||||
-- Code released under Unlicense <http://unlicense.org>.
|
||||
|
||||
-- Get the latest version of this file at:
|
||||
-- https://raw.githubusercontent.com/minetest-mods/intllib/master/lib/intllib.lua
|
||||
|
||||
local function format(str, ...)
|
||||
local args = { ... }
|
||||
local function repl(escape, open, num, close)
|
||||
if escape == "" then
|
||||
local replacement = tostring(args[tonumber(num)])
|
||||
if open == "" then
|
||||
replacement = replacement..close
|
||||
end
|
||||
return replacement
|
||||
else
|
||||
return "@"..open..num..close
|
||||
end
|
||||
end
|
||||
return (str:gsub("(@?)@(%(?)(%d+)(%)?)", repl))
|
||||
end
|
||||
|
||||
local gettext, ngettext
|
||||
if minetest.get_modpath("intllib") then
|
||||
if intllib.make_gettext_pair then
|
||||
-- New method using gettext.
|
||||
gettext, ngettext = intllib.make_gettext_pair()
|
||||
else
|
||||
-- Old method using text files.
|
||||
gettext = intllib.Getter()
|
||||
end
|
||||
end
|
||||
|
||||
-- Fill in missing functions.
|
||||
|
||||
gettext = gettext or function(msgid, ...)
|
||||
return format(msgid, ...)
|
||||
end
|
||||
|
||||
ngettext = ngettext or function(msgid, msgid_plural, n, ...)
|
||||
return format(n==1 and msgid or msgid_plural, ...)
|
||||
end
|
||||
|
||||
return gettext, ngettext
|
@ -5,11 +5,11 @@ Copyright © 2012-2019 Hugo Locurcio and contributors.
|
||||
Licensed under the zlib license. See LICENSE.md for more information.
|
||||
--]]
|
||||
|
||||
local S = maptools.intllib
|
||||
local S = maptools.S
|
||||
|
||||
maptools.creative = maptools.config["hide_from_creative_inventory"]
|
||||
|
||||
-- Redefine cloud so that the admin pickaxe can mine it:
|
||||
-- Redefine cloud so that the admin pickaxe can mine it
|
||||
minetest.register_node(":default:cloud", {
|
||||
description = S("Cloud"),
|
||||
tiles = {"default_cloud.png"},
|
||||
@ -20,7 +20,6 @@ minetest.register_node(":default:cloud", {
|
||||
})
|
||||
|
||||
-- Nodes
|
||||
-- =====
|
||||
|
||||
minetest.register_node("maptools:black", {
|
||||
description = S("Black"),
|
||||
|
@ -5,7 +5,7 @@ Copyright © 2012-2019 Hugo Locurcio and contributors.
|
||||
Licensed under the zlib license. See LICENSE.md for more information.
|
||||
--]]
|
||||
|
||||
local S = maptools.intllib
|
||||
local S = maptools.S
|
||||
|
||||
maptools.creative = maptools.config["hide_from_creative_inventory"]
|
||||
|
||||
@ -66,9 +66,9 @@ minetest.register_on_punchnode(function(pos, node, puncher)
|
||||
" using an Admin Pickaxe."
|
||||
)
|
||||
-- The node is removed directly, which means it even works
|
||||
-- on non-empty containers and group-less nodes.
|
||||
-- on non-empty containers and group-less nodes
|
||||
minetest.remove_node(pos)
|
||||
-- Run node update actions like falling nodes.
|
||||
-- Run node update actions like falling nodes
|
||||
minetest.check_for_falling(pos)
|
||||
end
|
||||
end)
|
||||
|
Loading…
Reference in New Issue
Block a user