mirror of
https://github.com/4Evergreen4/death_messages.git
synced 2025-01-04 06:57:29 +01:00
Update mod.conf, reformat init.lua, and add luacheckrc
This commit is contained in:
parent
509c036d94
commit
c7b597995e
36
.luacheckrc
Normal file
36
.luacheckrc
Normal 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
|
@ -7,7 +7,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:
|
||||||
|
104
init.lua
104
init.lua
@ -16,13 +16,13 @@ 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.
|
||||||
@ -30,72 +30,74 @@ local messages = {}
|
|||||||
|
|
||||||
-- Lava death messages
|
-- Lava death messages
|
||||||
messages.lava = {
|
messages.lava = {
|
||||||
" melted into a ball of fire.",
|
" melted into a ball of fire.",
|
||||||
" thought lava was cool.",
|
" thought lava was cool.",
|
||||||
" melted into a ball of fire.",
|
" melted into a ball of fire.",
|
||||||
" couldn't resist that warm glow of lava.",
|
" couldn't resist that warm glow of lava.",
|
||||||
" dug straight down.",
|
" dug straight down.",
|
||||||
" didn't know lava was hot."
|
" didn't know lava was hot."
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Drowning death messages
|
-- Drowning death messages
|
||||||
messages.water = {
|
messages.water = {
|
||||||
" drowned.",
|
" drowned.",
|
||||||
" ran out of air.",
|
" ran out of air.",
|
||||||
" failed at swimming lessons.",
|
" failed at swimming lessons.",
|
||||||
" tried to impersonate an anchor.",
|
" tried to impersonate an anchor.",
|
||||||
" forgot he wasn't a fish.",
|
" forgot he wasn't a fish.",
|
||||||
" blew one too many bubbles."
|
" blew one too many bubbles."
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Burning death messages
|
-- Burning death messages
|
||||||
messages.fire = {
|
messages.fire = {
|
||||||
" burned to a crisp.",
|
" burned to a crisp.",
|
||||||
" got a little too warm.",
|
" got a little too warm.",
|
||||||
" got too close to the camp fire.",
|
" got too close to the camp fire.",
|
||||||
" just got roasted, hotdog style.",
|
" just got roasted, hotdog style.",
|
||||||
" gout burned up. More light that way."
|
" got burned up. More light that way."
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Other death messages
|
-- Other death messages
|
||||||
messages.other = {
|
messages.other = {
|
||||||
" died.",
|
" died.",
|
||||||
" did something fatal.",
|
" did something fatal.",
|
||||||
" gave up on life.",
|
" gave up on life.",
|
||||||
" is somewhat dead now.",
|
" is somewhat dead now.",
|
||||||
" passed out -permanently."
|
" passed out -permanently."
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_message(mtype)
|
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[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
|
||||||
|
|
||||||
minetest.register_on_dieplayer(function(player)
|
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]
|
local node = minetest.registered_nodes[
|
||||||
if minetest.is_singleplayer() then
|
minetest.get_node(player:getpos()).name
|
||||||
player_name = "You"
|
]
|
||||||
end
|
if minetest.is_singleplayer() then
|
||||||
-- Death by lava
|
player_name = "You"
|
||||||
if node.groups.lava ~= nil then
|
end
|
||||||
minetest.chat_send_all(player_name .. get_message("lava"))
|
-- Death by lava
|
||||||
-- Death by drowning
|
if node.groups.lava ~= nil then
|
||||||
elseif player:get_breath() == 0 then
|
minetest.chat_send_all(player_name .. get_message("lava"))
|
||||||
minetest.chat_send_all(player_name .. get_message("water"))
|
-- Death by drowning
|
||||||
-- Death by fire
|
elseif player:get_breath() == 0 then
|
||||||
elseif node.name == "fire:basic_flame" then
|
minetest.chat_send_all(player_name .. get_message("water"))
|
||||||
minetest.chat_send_all(player_name .. get_message("fire"))
|
-- Death by fire
|
||||||
-- Death by something else
|
elseif node.name == "fire:basic_flame" then
|
||||||
else
|
minetest.chat_send_all(player_name .. get_message("fire"))
|
||||||
minetest.chat_send_all(player_name .. get_message("other"))
|
-- Death by something else
|
||||||
end
|
else
|
||||||
|
minetest.chat_send_all(player_name .. get_message("other"))
|
||||||
|
end
|
||||||
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-----------------------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
print("[Mod] "..title.." ["..version.."] ["..mname.."] Loaded...")
|
print("[Mod] "..title.." ["..version.."] ["..mname.."] Loaded...")
|
||||||
-----------------------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
6
mod.conf
6
mod.conf
@ -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
|
Loading…
Reference in New Issue
Block a user