17 Commits

Author SHA1 Message Date
4a294c2f14 Update README.txt 2024-08-17 12:55:46 -05:00
87145f0634 Archive repository, update README.txt 2024-08-17 12:49:20 -05:00
c7b597995e Update mod.conf, reformat init.lua, and add luacheckrc 2020-07-13 11:41:11 -04:00
509c036d94 Cleanup as well as adding screenshot and description 2016-01-14 19:34:10 -05:00
1579c47a58 Change drowning detection to player:get_breath() 2014-03-20 10:25:56 -04:00
f516e3904e Merge pull request #2 from webdesigner97/master
add support for groups lava and water
2014-03-20 08:44:47 -04:00
31aff1751a add support for groups lava and water 2014-03-20 12:32:08 +01:00
edd059747c Change license to GPL v3 2014-03-19 12:16:52 -04:00
24644bbb33 Bump version to 0.1.2 2014-03-19 10:50:44 -04:00
7bcdff90d9 Make random messages optional, and add more quips. 2014-03-19 10:48:40 -04:00
d2b31a3ffe Add random table of quips, and bump version to 0.1.1 2014-03-18 20:59:44 -04:00
02a8670823 Fix formatting in README (OCD much?) 2014-03-17 15:15:12 -04:00
327b43428c Clean up code a bit and use variables 2014-03-17 15:10:44 -04:00
0c6591fd0f Merge branch 'master' of https://github.com/4Evergreen4/death_messages 2014-03-17 13:52:03 -04:00
e78359248e Add depends.txt 2014-03-17 13:51:40 -04:00
bb2fe0f677 Fix README.md 2014-03-17 13:25:34 -04:00
163661c2b7 Add all files and bump version to 0.1 2014-03-17 13:23:56 -04:00
10 changed files with 109 additions and 254 deletions

36
.luacheckrc Normal file
View File

@ -0,0 +1,36 @@
read_globals = {
"DIR_DELIM",
"minetest", "core",
"dump", "dump2",
"vector",
"VoxelManip", "VoxelArea",
"PseudoRandom", "PcgRandom",
"ItemStack",
"Settings",
"unpack",
table = {
fields = {
"copy",
"indexof",
"insert_all",
"key_value_swap",
}
},
string = {
fields = {
"split",
"trim",
}
},
math = {
fields = {
"hypot",
"sign",
"factorial"
}
},
}
max_line_length = 80

0
LICENSE.txt Executable file → Normal file
View File

View File

@ -1,3 +1,13 @@
As of 2024-08-17, this mod will probably not be updated by me as I lost interest
in Minetest a long time ago and probably will not be coming back.
If you do want to make any changes, here was my list of TODO items that I never got around to:
- Update meta stuff (readme, version, mod.conf, etc.)
- Change settings file to not use do_file and add options for custom messages (with placement of player name(s) anywhere in the message)
- Add some kind of translation support (may be covered by custom messages)
- Use the new API features to poperly detect types of death that weren't feasible before
- Make a small API for registering custom messages for other mods (see dying by corium in technic)
____ _ _ __ __ ____ _ _ __ __
| _ \ ___ __ _| |_| |__ | \/ | ___ ___ ___ __ _ __ _ ___ ___ | _ \ ___ __ _| |_| |__ | \/ | ___ ___ ___ __ _ __ _ ___ ___
| | | |/ _ \/ _` | __| '_ \ | |\/| |/ _ \/ __/ __|/ _` |/ _` |/ _ \/ __| | | | |/ _ \/ _` | __| '_ \ | |\/| |/ _ \/ __/ __|/ _` |/ _` |/ _ \/ __|
@ -7,7 +17,7 @@
A Minetest mod which sends a chat message when a player dies. A Minetest mod which sends a chat message when a player dies.
Version: 0.1.3 Version: 0.1.4
License: GPL v3 (see LICENSE.txt) License: GPL v3 (see LICENSE.txt)
Dependencies: Dependencies:

0
depends.txt Executable file → Normal file
View File

281
init.lua Executable file → Normal file
View File

@ -16,285 +16,88 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
--]] --]]
----------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------
local title = "Death Messages" local title = "Death Messages"
local version = "0.1.2" local version = "0.1.4"
local mname = "death_messages" local mname = "death_messages"
----------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------
dofile(minetest.get_modpath("death_messages").."/settings.txt") dofile(minetest.get_modpath("death_messages").."/settings.txt")
----------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- A table of quips for death messages. The first item in each sub table is the -- A table of quips for death messages. The first item in each sub table is the
-- default message used when RANDOM_MESSAGES is disabled. -- default message used when RANDOM_MESSAGES is disabled.
local messages = {} local messages = {}
-- Another one to avoid double death messages
local whacked = {}
local logfile = minetest.get_worldpath() .. "/death_logs.txt"
-- Fill this table with sounds
local sounds = {
[1] = "death_messages_player_1",
[2] = "death_messages_player_2",
}
-- Lava death messages -- Lava death messages
messages.lava = { messages.lava = {
"%s thought lava was cool. / %s pensait que la lave était cool.", " melted into a ball of fire.",
"%s felt an urgent need to touch lava. / %s s'est senti obligé de toucher la lave.", " thought lava was cool.",
"%s fell in lava. / %s est tombé dans la lave.", " melted into a ball of fire.",
"%s died in lava. / %s est mort(e) dans de la lave.", " couldn't resist that warm glow of lava.",
"%s didn't know lava was very hot. / %s ne savait pas que la lave était vraiment chaude.", " dug straight down.",
"%s destroyed Sauron's ring. / %s a detruit l'anneau de Sauron.", " didn't know lava was hot."
"%s melted into a ball of fire. / %s est devenu une boule de feu",
"%s couldn't resist that warm glow of lava. / %s n'a pas pu se retenir face a cette chaude lueur de lave.",
"%s dug straight down. / %s a creusé a la verticale.",
} }
-- Drowning death messages -- Drowning death messages
messages.water = { messages.water = {
"%s lacked oxygen. / %s a manqué d'air.", " drowned.",
"%s ran out of air. / %s n'avait plus d'air.", " ran out of air.",
"%s tried to impersonate an anchor. / %s a essayé d'usurper l'identité d'une ancre.", " failed at swimming lessons.",
"%s forgot they were not a fish. / %s a oublié qu'il/elle n'était pas un poisson.", " tried to impersonate an anchor.",
"%s forgot they needed to breath underwater. / %s a oublié qu'il lui fallait respirer sous l'eau.", " forgot he wasn't a fish.",
"%s isn't good at swimming. / %s n'est pas bon(ne) en natation.", " blew one too many bubbles."
"%s looked for the secret of the Unicorn. / %s a cherché le secret de la licorne.",
"%s forgot their scaphander. / %s a oublié son scaphandre.",
"%s failed at swimming lessons. / %s a raté ses cours de natation.",
"%s blew one too many bubbles. / %s a expiré une bulle de trop.",
} }
-- Burning death messages -- Burning death messages
messages.fire = { messages.fire = {
"%s was a bit too hot. / %s a eu un peu trop chaud.", " burned to a crisp.",
"%s was too close to the fire. / %s a été trop près du feu.", " got a little too warm.",
"%s just got roasted. / %s vient de se faire rotir.", " got too close to the camp fire.",
"%s got burnt. / %s a été carbonisé.", " just got roasted, hotdog style.",
"%s thought they were the human torch. / %s s'est prit pour la torche.", " got burned up. More light that way."
"%s started a fire. / %s a allumé le feu.",
"%s burned to a crisp. / %s a brulé comme une chips.",
"%s got a little too warm. / %s a eu un peu trop chaud.",
"%s got too close to the camp fire. / %s s'est approché(e) trop près du feu de camp.",
"%s just got roasted, hotdog style. / %s vient de se faire rôtir façon hotdog.",
"%s was set aflame. More light that way. / %s s'est embrasé(e). Ça fait plus de lumière.",
}
-- Acid death messages
messages.acid = {
"%s has now parts of them missing. / %s a desormais des parties en moins.",
"%s discovered that acid is fun. / %s a decouvert que l'acide, c'est fun.",
"%s put their head where it melted. / %s a mis sa tête là ou elle a fondu.",
"%s discovered that their body in acid, it's like sugar in water. / %s a decouvert que son corps dans l'acide, c'est comme du sucre dans de l'eau.",
"%s thought they were swimming in apple juice. / %s a cru qu'il/elle se baignait dans du jus de pomme.",
"%s gave their body to make an infusion / %s a donné son corps pour faire une infusion.",
"%s drowned into the wrong liquid. / %s a bu la mauvaise tasse.",
"%s tried to test their body's solubility in acid. / %s a voulu tester la solubilité de son corps dans l'acide."
}
-- Quicksands death messages
messages.sand = {
"%s learnt that sand is less fluid than water. / %s a appris que le sable est moins fluide que l'eau.",
"%s joined the mummies. / %s a rejoint les momies.",
"%s got themselves buried. / %s s'est fait(e) ensevelir.",
"%s chose to become a fossil. / %s a choisi la voie de la fossilisation."
} }
-- Other death messages -- Other death messages
messages.other = { messages.other = {
"%s did something fatal to them. / %s a fait quelque chose qui lui a été fatal.", " died.",
"%s died. / %s est mort(e).", " did something fatal.",
"%s left this world. / %s n'est plus de ce monde.", " gave up on life.",
"%s reached miner's heaven. / %s a rejoint le paradis des mineurs.", " is somewhat dead now.",
"%s lost their life. / %s a perdu la vie.", " passed out -permanently."
"%s saw the light. / %s a vu la lumière.",
"%s fell from a bit too high. / %s est tombé(e) d'un peu trop haut.",
"%s slipped on a banana skin. / %s a glissé sur une peau de banane.",
"%s wanted to test their super powers. / %s a voulu tester ses super pouvoirs.",
"%s gave up on life. / %s a decidé de mourir.",
"%s is somewhat dead now. / %s est plus ou moins mort(e) maintenant.",
"%s passed out -permanently. / %s s'est evanoui(e) -pour toujours.",
"%s died under very mysterious conditions. / %s est mort(e) dans des conditions bien mystérieuses.",
} }
-- Whacking death messages function get_message(mtype)
messages.whacking = {
"%s got whacked by %s. / %s s'est pris une raclée de la part de %s.",
"%s's grave was dug by %s. / La tombe de %s a été creusée par %s.",
"%s got recycled by %s. / %s s'est fait recycler par %s.",
"%s surely annoyed %s. / %s embetait sûrement %s.",
"%s can't have any more offspring because of %s. / %s ne pourra plus avoir de descendance à cause de %s.",
"%s got beaten up by %s. / %s s'est fait rosser par %s.",
"%s had his suffering cut short by %s. / %s s'est vu abréger ses souffrances par %s.",
"%s died in excruciating pain because of %s's fault. / %s est mort(e) dans d'atroces souffrances par la faute de %s.",
"%s spent his last moments in the company of %s. / %s a vécu ses derniers instants en compagnie de %s.",
"%s's lineage was extinguished by %s. / La lignée de %s s'est éteinte à cause de %s.",
"%s wasn't as strong as %s. / %s a été moins fort(e) que %s.",
-- Need to fill
}
messages.monsters_whacking = {
"%s got whacked by a %s. / %s s'est pris une raclée de la part d'un %s.",
"Darwin said : %s was less adapted than a %s. / Darwin a dit : %s était moins adapté qu'un %s.",
"%s was transformed into a doormat by a %s. / %s s'est fait transformer en paillasson par un %s.",
"%s thought (s)he was stronger than a %s. / %s s'est cru plus fort(e) qu'un %s.",
"%s got kicked up by a %s. Next up... / %s s'est fait dégager par un %s. Au suivant...",
"%s felt well that he/she could not do anything against a %s. / %s sentait bien qu'il/elle ne pouvait pas faire le poids contre un %s.",
"%s versus %s? It's going bad! / %s contre un %s ? Ça tourne mal !",
"%s got a memorable spanking from %s. / %s a reçu une fessé mémorable de la part d'un %s.",
"%s thought to be able to tame a %s? History shows he was wrong. / %s croyait pouvoir dompter un %s ? L'histoire montre qu'il a eu tort.",
"%s didn't have the right reflex in front of a %s. / %s n'a pas eu le bon réflexe fasse à un %s.",
"But what did %s imagine versus a %s? Rest her soul. / Mais que s'est imaginé %s fasse à un %s ? Paix à son âme.",
"%s got shipped off to the afterlife in a hurry by a %s. / %s s'est fait expédier dans l'au-delà vite fait bien fait par un %s.",
"%s's attempt to reason with a %s didn't exactly pay off. / La tentative de %s pour raisonner un %s n'a pas vraiment porté ses fruits.",
"%s was severely shattered by a dirty %s. / %s s'est fait sévèrement éclater par une saleté de %s.",
-- Need to fill
}
-- Monsters
local monsters = {
["mobs_monster:fireball"] = "dungeon master",
["mobs_monster:dungeon_master"] = "dungeon master",
["mobs_monster:spider"] = "spider",
["mobs_monster:sand_monster"] = "sand monster",
["mobs_animal:cow"] = "cow",
["creeper:creeper"] = "creeper",
["pmobs:dog"] = "dog",
["slimes:greenbig"] = "big green slim",
["slimes:greenmedium"] = "medium green slim",
["slimes:greensmall"] = "small green slim",
["slimes:lavabig"] = "big lava slim",
["slimes:lavamedium"] = "medium lava slim",
["slimes:lavasmall"] = "small lava slim",
["pmobs:yeti"] = "yeti",
["pmobs:snowball"] = "yeti",
["pmobs:npc"] = "npc",
["pmobs:npc_female"] = "female npc",
["mobs_monster:oerkki"] = "oerkki",
["mobs_monster:stone_monster"] = "stone monster",
["mobs_monster:dirt_monster"] = "dirt monster",
["mobs_animal:goat"] = "goat",
["pmobs:wolf"] = "wolf",
["mobs_monster:tree_monster"] = "tree monster",
["mobs_monster:mese_arrow"] = "mese monster",
["zombie:zombie"] = "zombie",
["mobs_monster:minotaur"] = "minotaur",
["mobs_animal:pumba"] = "warthog",
["tsm_pyramids:mummy"] = "mummy",
["mobs_sharks:shark_lg"] = "large shark",
["mobs_sharks:shark_md"] = "medium shark",
["mobs_sharks:shark_sm"] = "small shark",
["mobs_crocs:crocodile"] = "crocodile",
["mobs_crocs:crocodile_float"] = "crocodile",
["mobs_crocs:crocodile_swim"] = "crocodile",
["mobs_monster:lava_flan"] = "lava flan",
["mobs_animal:bee"] = "bee",
["mobs_animal:bunny"] = "evil bunny",
-- ["mobs:pumpking"] = "pumpking",
-- ["mobs:pumpboom"] = "pumpboom",
-- ["mobs:mese_dragon"] = "mese_dragon",
}
local function broadcast_death(msg)
minetest.chat_send_all(msg)
local logfilep = io.open(logfile, "a")
logfilep:write(os.date("[%Y-%m-%d %H:%M:%S] ") .. msg .. "\n")
logfilep:close()
if irc then
irc.say(msg)
end
end
local function sound_play_all(dead)
for _, p in ipairs(minetest.get_connected_players()) do
local player_name = p:get_player_name()
if player_name and player_name ~= dead then
minetest.sound_play("death_messages_people_1",{to_player=player_name, gain=1})
end
end
end
minetest.register_on_punchplayer(function(player, hitter, time,
tool_caps, dir, damage)
if player:get_hp() - damage <= 0 and not whacked[player:get_player_name()] then
local player_name = player:get_player_name()
local death_message
if hitter:is_player() then
death_message = string.format(messages.whacking[math.random(1,#messages.whacking)], player_name, hitter:get_player_name(), player_name, hitter:get_player_name())
else
local entity_name = monsters[hitter:get_luaentity().name] or "monster"
death_message = string.format(messages.monsters_whacking[math.random(1, #messages.monsters_whacking)], player_name, entity_name, player_name, entity_name)
end
broadcast_death(death_message)
minetest.sound_play(sounds[math.random(1,#sounds)],{to_player=player_name,gain=1})
sound_play_all(player_name)
whacked[player_name] = true
end
end)
minetest.register_on_leaveplayer(function(player)
whacked[player:get_player_name()] = nil
end)
minetest.register_on_respawnplayer(function(player)
whacked[player:get_player_name()] = nil
end)
local function get_message(mtype)
if RANDOM_MESSAGES then if RANDOM_MESSAGES then
return messages[mtype][math.random(1, #messages[mtype])] return messages[mtype][math.random(1, #messages[mtype])]
else else
return messages[mtype][1] -- 1 is the index for the non-random message return messages[1] -- 1 is the index for the non-random message
end end
end end
local function find_node(pos, name) minetest.register_on_dieplayer(function(player)
return minetest.find_node_near(pos, 1, name, true)
end
minetest.register_on_dieplayer(
function(player)
local player_name = player:get_player_name() local player_name = player:get_player_name()
local node = minetest.registered_nodes[
minetest.get_node(player:getpos()).name
]
if minetest.is_singleplayer() then if minetest.is_singleplayer() then
player_name = "You" player_name = "You"
end end
local death_message = ""
if not whacked[player_name] then
-- Death by lava -- Death by lava
if find_node(player:get_pos(), "group:lava") then if node.groups.lava ~= nil then
death_message = get_message("lava") minetest.chat_send_all(player_name .. get_message("lava"))
-- Death by acid
elseif find_node(player:get_pos(), "group:acid") then
death_message = get_message("acid")
-- Death by drowning -- Death by drowning
elseif player:get_breath() == 0 and find_node(player:get_pos(), "group:water") then elseif player:get_breath() == 0 then
death_message = get_message("water") minetest.chat_send_all(player_name .. get_message("water"))
-- Death by fire -- Death by fire
elseif find_node(player:get_pos(), "fire:basic_flame") then elseif node.name == "fire:basic_flame" then
death_message = get_message("fire") minetest.chat_send_all(player_name .. get_message("fire"))
-- Death in quicksand
elseif player:get_breath() == 0 and find_node(player:get_pos(), {"nalc:sand_source", "nalc:sand_flowing"}) then
death_message = get_message("sand")
-- Death by something else -- Death by something else
else else
death_message = get_message("other") minetest.chat_send_all(player_name .. get_message("other"))
end end
-- Actually tell something
death_message = string.format(death_message, player_name, player_name)
broadcast_death(death_message)
minetest.sound_play(sounds[math.random(1,#sounds)], {to_player=player_name,gain=1})
sound_play_all(player_name)
whacked[player_name] = true
end
end) end)
----------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------
minetest.log("action", "[Mod] "..title.." ["..version.."] ["..mname.."] Loaded...") print("[Mod] "..title.." ["..version.."] ["..mname.."] Loaded...")
----------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------

View File

@ -1 +1,7 @@
name = death_messages name = death_messages
title = Death Messages
author = Evergreen
description = Sends a chat message when a player dies (with customizable messages)
license = GPL v3
forum = https://forum.minetest.net/viewtopic.php?t=8821
version = 0.1.4

0
settings.txt Executable file → Normal file
View File

Binary file not shown.

Binary file not shown.

Binary file not shown.