From e201501aef758ec670d33ce69f36462f99497b6c Mon Sep 17 00:00:00 2001 From: tenplus1 Date: Sat, 9 Nov 2024 16:42:46 +0000 Subject: [PATCH] add russian translation and ondie function (thx skybuilder1717) --- README.md | 3 ++- api.txt | 4 ++++ init.lua | 28 +++++++++++++++++++--------- locale/invisibility.ru.tr | 16 ++++++++++++++++ locale/template.txt | 16 ++++++++++++++++ settingtypes.txt | 1 + 6 files changed, 58 insertions(+), 10 deletions(-) create mode 100644 locale/invisibility.ru.tr create mode 100644 locale/template.txt create mode 100644 settingtypes.txt diff --git a/README.md b/README.md index 880d68d..02d6cc2 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Invisibility Potion by TenPlus1 This mod lets you craft an invisibility potion using one of each sapling (tree, jungle, pine, acacia, aspen, bush, acacia bush), a red mushroom and glass bottle. -Use potion to hide yourself AND nametag (0.4.15+ only) for 3 minutes. +Use potion to hide yourself AND nametag (5.0.0+ only) for 3 minutes. Server admin can use the '/vanish ' command to hide/unhide players or themselves by leaving it blank. @@ -16,3 +16,4 @@ Changelog: - 0.3 - Potions can now be stacked - 0.4 - Potion recipe changed now that Nyan Cat no longer in default game - 0.5 - Use newer functions, Minetest 0.4.16 and anove needed to run + - 0.6 - Make invisibility function global for API use, add time setting. diff --git a/api.txt b/api.txt index 5df45df..b9e4e2b 100644 --- a/api.txt +++ b/api.txt @@ -15,3 +15,7 @@ player in their worlds e.g. /vanish -- toggle their own visibility /vanish -- toggle the visibility of another player. + + +Players can alter the 'invisibility.effect_time' setting to change the amount of time +they remain invisible [default is 180 seconds], with 10 second warning before running out. diff --git a/init.lua b/init.lua index 57776e8..3345ed0 100644 --- a/init.lua +++ b/init.lua @@ -1,10 +1,13 @@ -invisibility = {} +-- global + +invisibility = { + effect_time = minetest.settings:get("invisibility.effect_time") or 180 -- 3 mins +} -local effect_time = 180 -- 3 minutes local S = minetest.get_translator("invisibility") -- translation support --- reset player invisibility if they go offline +-- reset player invisibility if they go offline or die minetest.register_on_leaveplayer(function(player) @@ -15,6 +18,10 @@ minetest.register_on_leaveplayer(function(player) end end) +minetest.register_on_dieplayer(function(player) + invisibility.invisible(player, nil) +end) + -- creative check local creative_mode_cache = minetest.settings:get_bool("creative_mode") @@ -88,7 +95,7 @@ minetest.register_node("invisibility:potion", { pos = pos, gain = 1.0, max_hear_distance = 5}, true) -- display 10 second warning - minetest.after(effect_time - 10, function() + minetest.after(invisibility.effect_time - 10, function() if invisibility[name] and user:get_pos() then @@ -98,7 +105,7 @@ minetest.register_node("invisibility:potion", { end) -- make player visible 5 minutes later - minetest.after(effect_time, function() + minetest.after(invisibility.effect_time, function() if invisibility[name] and user:get_pos() then @@ -155,7 +162,7 @@ minetest.register_craft( { minetest.register_chatcommand("vanish", { params = "", - description = "Make player invisible", + description = S("Make player invisible"), privs = {server = true}, func = function(name, param) @@ -168,17 +175,20 @@ minetest.register_chatcommand("vanish", { -- player not online elseif param ~= "" then - return false, "Player " .. param .. " is not online!" + return false, S("Player @1 is offline!", param) end local player = minetest.get_player_by_name(name) + local msg -- hide / show player if invisibility[name] then - invisibility.invisible(player, nil) + invisibility.invisible(player, nil) ; msg = "visible" else - invisibility.invisible(player, true) + invisibility.invisible(player, true) ; msg = "invisible" end + + return true, S("Player @1 is now @2!", name, S(msg)) end }) diff --git a/locale/invisibility.ru.tr b/locale/invisibility.ru.tr new file mode 100644 index 0000000..f0d67b9 --- /dev/null +++ b/locale/invisibility.ru.tr @@ -0,0 +1,16 @@ +# textdomain: invisibility + +# Items +Invisibility Potion=Зелье Невидимости + +# Messages +>>> You are already invisible!=>>> Вы уже невидимы! +>>> You have 10 seconds before invisibility wears off!=>>> У вас 10 секунд, до того как невидимость спадёт! + +# Command +Make player invisible=Делает игрока невидимым +Player @1 is offline!=Игрок @1 не в сети! +Player @1 is now @2!=Теперь игрок @1 @2! + +visible=видимый +invisible=невидимый diff --git a/locale/template.txt b/locale/template.txt new file mode 100644 index 0000000..6d83435 --- /dev/null +++ b/locale/template.txt @@ -0,0 +1,16 @@ +# textdomain: invisibility + +# Items +Invisibility Potion= + +# Messages +>>> You are already invisible!= +>>> You have 10 seconds before invisibility wears off!= + +# Command +Make player invisible= +Player @1 is offline!= +Player @1 is now @2!= + +visible= +invisible= diff --git a/settingtypes.txt b/settingtypes.txt new file mode 100644 index 0000000..2aedf20 --- /dev/null +++ b/settingtypes.txt @@ -0,0 +1 @@ +invisibility.effect_time (How many seconds player is invisible) float 180