Adding of sunburn and hbhunger

master
A. Demant 2018-09-06 18:31:32 +02:00
parent 7dbae77cd4
commit 493b395231
1 changed files with 19 additions and 5 deletions

View File

@ -34,6 +34,8 @@ local lstamina = 100
-- check if thirsty is used and death may occured by exhausting
local mthirsty = minetest.get_modpath("thirsty")
local lthirsty = 100
local msunburn = minetest.get_modpath("sunburn")
local lsunburn = 0
-- A table of quips for death messages. The first item in each sub table is the
-- default message used when RANDOM_MESSAGES is disabled.
@ -148,6 +150,12 @@ messages.thirst = {en = {
de = {
" verdurstete."
}}
messages.sunburn = {en = {
" burned by sun."
},
de = {
" ist von der Sonne verbrannt."
}}
-- PVP Messages
messages.pvp = {en = {
@ -264,13 +272,15 @@ minetest.register_on_dieplayer(function(player,reason)
if minetest.is_singleplayer() then
player_name = "You"
end
if mstamina ~= nil then
lstamina = get_int_attribute(player, "stamina:level")
end
if mthirsty ~= nil then
lthirsty = thirsty.get_thirst_factor(player)
end
if msunburn ~= nil then
lsunburn = PPA.get_value(player, "sunburn_sunburn")
end
-- Death by lava
if node.name == "default:lava_source" then
@ -311,14 +321,18 @@ minetest.register_on_dieplayer(function(player,reason)
string.char(0x1b).."(c@#00CED1)"..player_name ..
string.char(0x1b).."(c@#ff0000)"..get_message("toxic"))
--player:setpos(death)
elseif lstamina <= 1 then
minetest.chat_send_all(
string.char(0x1b).."(c@#00CED1)"..player_name ..
string.char(0x1b).."(c@#ff0000)"..get_message("exhausted"))
elseif lthirsty <= 1 then
minetest.chat_send_all(
string.char(0x1b).."(c@#00CED1)"..player_name ..
string.char(0x1b).."(c@#ff0000)"..get_message("thirst"))
elseif lstamina <= 1 then
minetest.chat_send_all(
string.char(0x1b).."(c@#00CED1)"..player_name ..
string.char(0x1b).."(c@#ff0000)"..get_message("exhausted"))
elseif lsunburn >= 19 then
minetest.chat_send_all(
string.char(0x1b).."(c@#00CED1)"..player_name ..
string.char(0x1b).."(c@#ff0000)"..get_message("sunburn"))
-- Death by something else
else
minetest.chat_send_all(