forked from mtcontrib/death_messages
Clean up code a bit and use variables
This commit is contained in:
parent
81e34709d6
commit
eb60e2fdcf
20
init.lua
20
init.lua
@ -5,19 +5,25 @@ local mname = "death_messages"
|
||||
-----------------------------------------------------------------------------------------------
|
||||
|
||||
minetest.register_on_dieplayer(function(player)
|
||||
local player_name = player:get_player_name()
|
||||
if minetest.is_singleplayer() then
|
||||
player_name = "You"
|
||||
end
|
||||
-- Death by lava
|
||||
if minetest.get_node(player:getpos(name)).name == "default:lava_source" or minetest.get_node(player:getpos(name)).name == "default:lava_flowing" then
|
||||
minetest.chat_send_all(player:get_player_name().." melted into a ball of fire.")
|
||||
local nodename = minetest.get_node(player:getpos()).name
|
||||
if nodename == "default:lava_source" or nodename == "default:lava_flowing" then
|
||||
minetest.chat_send_all(player_name .. " melted into a ball of fire.")
|
||||
-- Death by drowning
|
||||
elseif minetest.get_node(player:getpos(name)).name == "default:water_source" or minetest.get_node(player:getpos(name)).name == "default:water_flowing" then
|
||||
minetest.chat_send_all(player:get_player_name().." ran out of air.")
|
||||
elseif nodename == "default:water_source" or nodename == "default:water_flowing" then
|
||||
minetest.chat_send_all(player_name .. " ran out of air.")
|
||||
--Death by fire
|
||||
elseif minetest.get_node(player:getpos(name)).name == "fire:basic_flame" then
|
||||
minetest.chat_send_all(player:get_player_name().." burned up.")
|
||||
elseif nodename == "fire:basic_flame" then
|
||||
minetest.chat_send_all(player_name .. " burned up.")
|
||||
--Death by something else
|
||||
else
|
||||
minetest.chat_send_all(player:get_player_name().." died.")
|
||||
minetest.chat_send_all(player_name .. " died.")
|
||||
end
|
||||
|
||||
end)
|
||||
|
||||
-----------------------------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user