add translation support
This commit is contained in:
parent
6653c6bf97
commit
c348c4be5d
@ -1,3 +0,0 @@
|
|||||||
default
|
|
||||||
vessels
|
|
||||||
flowers
|
|
22
init.lua
22
init.lua
@ -4,6 +4,20 @@ invisibility = {}
|
|||||||
local effect_time = 180 -- 3 minutes
|
local effect_time = 180 -- 3 minutes
|
||||||
|
|
||||||
|
|
||||||
|
-- translation support
|
||||||
|
local S
|
||||||
|
if minetest.get_translator then
|
||||||
|
S = minetest.get_translator("invisibility") -- 5.x translation function
|
||||||
|
else -- boilerplate function
|
||||||
|
S = function(str, ...)
|
||||||
|
local args = {...}
|
||||||
|
return str:gsub("@%d+", function(match)
|
||||||
|
return args[tonumber(match:sub(2))]
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
-- reset player invisibility if they go offline
|
-- reset player invisibility if they go offline
|
||||||
minetest.register_on_leaveplayer(function(player)
|
minetest.register_on_leaveplayer(function(player)
|
||||||
|
|
||||||
@ -17,14 +31,14 @@ end)
|
|||||||
|
|
||||||
-- creative check
|
-- creative check
|
||||||
local creative_mode_cache = minetest.settings:get_bool("creative_mode")
|
local creative_mode_cache = minetest.settings:get_bool("creative_mode")
|
||||||
function is_creative(name)
|
local function is_creative(name)
|
||||||
return creative_mode_cache or minetest.check_player_privs(name, {creative = true})
|
return creative_mode_cache or minetest.check_player_privs(name, {creative = true})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- invisibility potion
|
-- invisibility potion
|
||||||
minetest.register_node("invisibility:potion", {
|
minetest.register_node("invisibility:potion", {
|
||||||
description = "Invisibility Potion",
|
description = S("Invisibility Potion"),
|
||||||
drawtype = "plantlike",
|
drawtype = "plantlike",
|
||||||
tiles = {"invisibility_potion.png"},
|
tiles = {"invisibility_potion.png"},
|
||||||
inventory_image = "invisibility_potion.png",
|
inventory_image = "invisibility_potion.png",
|
||||||
@ -47,7 +61,7 @@ minetest.register_node("invisibility:potion", {
|
|||||||
-- are we already invisible?
|
-- are we already invisible?
|
||||||
if invisibility[name] then
|
if invisibility[name] then
|
||||||
|
|
||||||
minetest.chat_send_player(name, ">>> You are already invisible!")
|
minetest.chat_send_player(name, S(">>> You are already invisible!"))
|
||||||
|
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
@ -67,7 +81,7 @@ minetest.register_node("invisibility:potion", {
|
|||||||
and user:get_pos() then
|
and user:get_pos() then
|
||||||
|
|
||||||
minetest.chat_send_player(name,
|
minetest.chat_send_player(name,
|
||||||
">>> You have 10 seconds before invisibility wears off!")
|
S(">>> You have 10 seconds before invisibility wears off!"))
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user