From f6176e63577bcae1593986d38347169a0924685b Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Tue, 5 Jan 2016 02:57:10 +0000 Subject: [PATCH] Fix hpregen whilst dead --- mods/hpregen/init.lua | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/mods/hpregen/init.lua b/mods/hpregen/init.lua index 32a6c4f..7851e33 100644 --- a/mods/hpregen/init.lua +++ b/mods/hpregen/init.lua @@ -9,11 +9,14 @@ end local function regen_all() for _, player in pairs(minetest.get_connected_players()) do - local newhp = player:get_hp() + regen_amount - if newhp > 20 then - newhp = 20 + local oldhp = player:get_hp() + if oldhp > 0 then + local newhp = oldhp + regen_amount + if newhp > 20 then + newhp = 20 + end + player:set_hp(newhp) end - player:set_hp(newhp) end minetest.after(regen_interval, regen_all) end