This repository has been archived by the owner on Aug 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
init.lua
103 lines (90 loc) · 3.33 KB
/
init.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
--[[
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/>.
--]]
--------------------------------------------------------------------------------
local title = "Death Messages"
local version = "0.1.4"
local mname = "death_messages"
--------------------------------------------------------------------------------
dofile(minetest.get_modpath("death_messages").."/settings.txt")
--------------------------------------------------------------------------------
-- A table of quips for death messages. The first item in each sub table is the
-- default message used when RANDOM_MESSAGES is disabled.
local messages = {}
-- Lava death messages
messages.lava = {
" 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."
}
-- Drowning death messages
messages.water = {
" 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."
}
-- Burning death messages
messages.fire = {
" 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."
}
-- Other death messages
messages.other = {
" died.",
" did something fatal.",
" gave up on life.",
" is somewhat dead now.",
" passed out -permanently."
}
function get_message(mtype)
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
end
minetest.register_on_dieplayer(function(player)
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
end)
--------------------------------------------------------------------------------
print("[Mod] "..title.." ["..version.."] ["..mname.."] Loaded...")
--------------------------------------------------------------------------------