From 493b39523199d51238c496b5870125e917e605c4 Mon Sep 17 00:00:00 2001 From: "A. Demant" Date: Thu, 6 Sep 2018 18:31:32 +0200 Subject: [PATCH] Adding of sunburn and hbhunger --- init.lua | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/init.lua b/init.lua index dd1d5b5..abc3d24 100644 --- a/init.lua +++ b/init.lua @@ -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(