mirror of
https://github.com/4Evergreen4/death_messages.git
synced 2025-03-28 05:40:22 +01:00
Make death-messages translatable
Now, messages will be sent to each player invididually in their respective language (if it has a translation, of course).
This commit is contained in:
parent
c7b597995e
commit
99dc812fbd
85
init.lua
85
init.lua
@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
local title = "Death Messages"
|
local title = "Death Messages"
|
||||||
local version = "0.1.4"
|
local version = "0.1.4"
|
||||||
local mname = "death_messages"
|
local mname = "death_messages"
|
||||||
|
local S = minetest.get_translator("death_messages")
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
dofile(minetest.get_modpath("death_messages").."/settings.txt")
|
dofile(minetest.get_modpath("death_messages").."/settings.txt")
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
@ -30,40 +31,40 @@ local messages = {}
|
|||||||
|
|
||||||
-- Lava death messages
|
-- Lava death messages
|
||||||
messages.lava = {
|
messages.lava = {
|
||||||
" melted into a ball of fire.",
|
S("%s melted into a ball of fire."),
|
||||||
" thought lava was cool.",
|
S("%s thought lava was cool."),
|
||||||
" melted into a ball of fire.",
|
S("%s melted into a ball of fire."),
|
||||||
" couldn't resist that warm glow of lava.",
|
S("%s couldn't resist that warm glow of lava."),
|
||||||
" dug straight down.",
|
S("%s dug straight down."),
|
||||||
" didn't know lava was hot."
|
S("%s didn't know lava was hot.")
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Drowning death messages
|
-- Drowning death messages
|
||||||
messages.water = {
|
messages.water = {
|
||||||
" drowned.",
|
S("%s drowned."),
|
||||||
" ran out of air.",
|
S("%s ran out of air."),
|
||||||
" failed at swimming lessons.",
|
S("%s failed at swimming lessons."),
|
||||||
" tried to impersonate an anchor.",
|
S("%s tried to impersonate an anchor."),
|
||||||
" forgot he wasn't a fish.",
|
S("%s forgot they aren't a fish."),
|
||||||
" blew one too many bubbles."
|
S("%s blew one too many bubbles.")
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Burning death messages
|
-- Burning death messages
|
||||||
messages.fire = {
|
messages.fire = {
|
||||||
" burned to a crisp.",
|
S("%s burned to a crisp."),
|
||||||
" got a little too warm.",
|
S("%s got a little too warm."),
|
||||||
" got too close to the camp fire.",
|
S("%s got too close to the camp fire."),
|
||||||
" just got roasted, hotdog style.",
|
S("%s just got roasted, hotdog style."),
|
||||||
" got burned up. More light that way."
|
S("%s got burned up. More light that way.")
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Other death messages
|
-- Other death messages
|
||||||
messages.other = {
|
messages.other = {
|
||||||
" died.",
|
S("%s died."),
|
||||||
" did something fatal.",
|
S("%s did something fatal."),
|
||||||
" gave up on life.",
|
S("%s gave up on life."),
|
||||||
" is somewhat dead now.",
|
S("%s is somewhat dead now."),
|
||||||
" passed out -permanently."
|
S("%s passed out -permanently.")
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_message(mtype)
|
function get_message(mtype)
|
||||||
@ -75,27 +76,37 @@ function get_message(mtype)
|
|||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_on_dieplayer(function(player)
|
minetest.register_on_dieplayer(function(player)
|
||||||
local player_name = player:get_player_name()
|
local cadaver_name = player:get_player_name()
|
||||||
local node = minetest.registered_nodes[
|
local node = minetest.registered_nodes[
|
||||||
minetest.get_node(player:getpos()).name
|
minetest.get_node(player:getpos()).name
|
||||||
]
|
]
|
||||||
if minetest.is_singleplayer() then
|
if minetest.is_singleplayer() then
|
||||||
player_name = "You"
|
cadaver_name = S("You")
|
||||||
end
|
|
||||||
-- Death by lava
|
|
||||||
if node.groups.lava ~= nil then
|
|
||||||
minetest.chat_send_all(player_name .. get_message("lava"))
|
|
||||||
-- Death by drowning
|
|
||||||
elseif player:get_breath() == 0 then
|
|
||||||
minetest.chat_send_all(player_name .. get_message("water"))
|
|
||||||
-- Death by fire
|
|
||||||
elseif node.name == "fire:basic_flame" then
|
|
||||||
minetest.chat_send_all(player_name .. get_message("fire"))
|
|
||||||
-- Death by something else
|
|
||||||
else
|
|
||||||
minetest.chat_send_all(player_name .. get_message("other"))
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Death by something else
|
||||||
|
local msg = get_message("other")
|
||||||
|
-- Death by lava
|
||||||
|
if node.groups.lava ~= nil then
|
||||||
|
msg = get_message("lava")
|
||||||
|
-- Death by drowning
|
||||||
|
elseif player:get_breath() == 0 then
|
||||||
|
msg = get_message("water")
|
||||||
|
-- Death by fire
|
||||||
|
elseif node.name == "fire:basic_flame" then
|
||||||
|
msg = get_message("fire")
|
||||||
|
end
|
||||||
|
|
||||||
|
for _, player in ipairs(minetest.get_connected_players()) do
|
||||||
|
local ricevee_name = player:get_player_name()
|
||||||
|
local info = minetest.get_player_information(ricevee_name)
|
||||||
|
local lang = (info and info.lang_code) or "en"
|
||||||
|
local translated_msg = minetest.get_translated_string(lang, msg)
|
||||||
|
|
||||||
|
if ricevee_name then
|
||||||
|
minetest.chat_send_player(ricevee_name, translated_msg:gsub("%%s", cadaver_name))
|
||||||
|
end
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
23
locale/template.txt
Normal file
23
locale/template.txt
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# textdomain: death_messages
|
||||||
|
%s melted into a ball of fire.=
|
||||||
|
%s thought lava was cool.=
|
||||||
|
%s couldn't resist that warm glow of lava.=
|
||||||
|
%s dug straight down.=
|
||||||
|
%s didn't know lava was hot.=
|
||||||
|
%s drowned.=
|
||||||
|
%s ran out of air.=
|
||||||
|
%s failed at swimming lessons.=
|
||||||
|
%s tried to impersonate an anchor.=
|
||||||
|
%s forgot they aren't a fish.=
|
||||||
|
%s blew one too many bubbles.=
|
||||||
|
%s burned to a crisp.=
|
||||||
|
%s got a little too warm.=
|
||||||
|
%s got too close to the camp fire.=
|
||||||
|
%s just got roasted, hotdog style.=
|
||||||
|
%s got burned up. More light that way.=
|
||||||
|
%s died.=
|
||||||
|
%s did something fatal.=
|
||||||
|
%s gave up on life.=
|
||||||
|
%s is somewhat dead now.=
|
||||||
|
%s passed out -permanently.=
|
||||||
|
You=
|
Loading…
x
Reference in New Issue
Block a user