From ef028529396303ef5b09951a4ba76a463363d1ec Mon Sep 17 00:00:00 2001 From: 4Evergreen4 Date: Mon, 13 Jul 2020 11:41:11 -0400 Subject: [PATCH] Update mod.conf, reformat init.lua, and add luacheckrc --- .luacheckrc | 36 ++++++++++++++++++ README.txt | 2 +- init.lua | 104 ++++++++++++++++++++++++++-------------------------- mod.conf | 6 +++ 4 files changed, 96 insertions(+), 52 deletions(-) create mode 100644 .luacheckrc diff --git a/.luacheckrc b/.luacheckrc new file mode 100644 index 0000000..6caea83 --- /dev/null +++ b/.luacheckrc @@ -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 \ No newline at end of file diff --git a/README.txt b/README.txt index ec577ed..05106e1 100644 --- a/README.txt +++ b/README.txt @@ -7,7 +7,7 @@ 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) Dependencies: diff --git a/init.lua b/init.lua index 3601c1e..152f2b2 100644 --- a/init.lua +++ b/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 . --]] ------------------------------------------------------------------------------------------------ +-------------------------------------------------------------------------------- local title = "Death Messages" -local version = "0.1.2" +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. @@ -30,72 +30,74 @@ 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." + " 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." + " 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.", - " gout burned up. More light that way." + " 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." + " 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 + 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 + 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...") ------------------------------------------------------------------------------------------------ +-------------------------------------------------------------------------------- diff --git a/mod.conf b/mod.conf index e775487..1b0b66d 100644 --- a/mod.conf +++ b/mod.conf @@ -1 +1,7 @@ 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 \ No newline at end of file