2016-01-15 01:34:10 +01:00
|
|
|
--[[
|
|
|
|
death_messages - A Minetest mod which sends a chat message when a player dies.
|
|
|
|
Copyright (C) 2016 EvergreenTree
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
--]]
|
|
|
|
|
2020-07-13 17:41:11 +02:00
|
|
|
--------------------------------------------------------------------------------
|
2016-01-15 01:34:10 +01:00
|
|
|
local title = "Death Messages"
|
2020-07-13 17:41:11 +02:00
|
|
|
local version = "0.1.4"
|
2016-01-15 01:34:10 +01:00
|
|
|
local mname = "death_messages"
|
2020-07-13 17:41:11 +02:00
|
|
|
--------------------------------------------------------------------------------
|
2014-03-19 15:48:40 +01:00
|
|
|
dofile(minetest.get_modpath("death_messages").."/settings.txt")
|
2020-07-13 17:41:11 +02:00
|
|
|
--------------------------------------------------------------------------------
|
2014-03-19 01:59:44 +01:00
|
|
|
|
2016-01-15 01:34:10 +01:00
|
|
|
-- A table of quips for death messages. The first item in each sub table is the
|
|
|
|
-- default message used when RANDOM_MESSAGES is disabled.
|
2014-03-19 01:59:44 +01:00
|
|
|
local messages = {}
|
|
|
|
|
|
|
|
-- Lava death messages
|
|
|
|
messages.lava = {
|
2020-07-13 17:41:11 +02:00
|
|
|
" melted into a ball of fire.",
|
|
|
|
" thought lava was cool.",
|
|
|
|
" melted into a ball of fire.",
|
|
|
|
" couldn't resist that warm glow of lava.",
|
|
|
|
" dug straight down.",
|
|
|
|
" didn't know lava was hot."
|
2014-03-19 01:59:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
-- Drowning death messages
|
|
|
|
messages.water = {
|
2020-07-13 17:41:11 +02:00
|
|
|
" drowned.",
|
|
|
|
" ran out of air.",
|
|
|
|
" failed at swimming lessons.",
|
|
|
|
" tried to impersonate an anchor.",
|
|
|
|
" forgot he wasn't a fish.",
|
|
|
|
" blew one too many bubbles."
|
2014-03-19 01:59:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
-- Burning death messages
|
|
|
|
messages.fire = {
|
2020-07-13 17:41:11 +02:00
|
|
|
" burned to a crisp.",
|
|
|
|
" got a little too warm.",
|
|
|
|
" got too close to the camp fire.",
|
|
|
|
" just got roasted, hotdog style.",
|
|
|
|
" got burned up. More light that way."
|
2014-03-19 01:59:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
-- Other death messages
|
|
|
|
messages.other = {
|
2020-07-13 17:41:11 +02:00
|
|
|
" died.",
|
|
|
|
" did something fatal.",
|
|
|
|
" gave up on life.",
|
|
|
|
" is somewhat dead now.",
|
|
|
|
" passed out -permanently."
|
2014-03-19 01:59:44 +01:00
|
|
|
}
|
|
|
|
|
2016-01-15 01:34:10 +01:00
|
|
|
function get_message(mtype)
|
2020-07-13 17:41:11 +02:00
|
|
|
if RANDOM_MESSAGES then
|
|
|
|
return messages[mtype][math.random(1, #messages[mtype])]
|
|
|
|
else
|
|
|
|
return messages[1] -- 1 is the index for the non-random message
|
|
|
|
end
|
2016-01-15 01:34:10 +01:00
|
|
|
end
|
2014-03-19 01:59:44 +01:00
|
|
|
|
2016-01-15 01:34:10 +01:00
|
|
|
minetest.register_on_dieplayer(function(player)
|
2020-07-13 17:41:11 +02:00
|
|
|
local player_name = player:get_player_name()
|
|
|
|
local node = minetest.registered_nodes[
|
|
|
|
minetest.get_node(player:getpos()).name
|
|
|
|
]
|
|
|
|
if minetest.is_singleplayer() then
|
|
|
|
player_name = "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
|
2014-03-17 20:10:44 +01:00
|
|
|
|
2016-01-15 01:34:10 +01:00
|
|
|
end)
|
2014-03-17 18:23:56 +01:00
|
|
|
|
2020-07-13 17:41:11 +02:00
|
|
|
--------------------------------------------------------------------------------
|
2014-03-17 18:23:56 +01:00
|
|
|
print("[Mod] "..title.." ["..version.."] ["..mname.."] Loaded...")
|
2020-07-13 17:41:11 +02:00
|
|
|
--------------------------------------------------------------------------------
|