Fix hpregen whilst dead

This commit is contained in:
rubenwardy 2016-01-05 02:57:10 +00:00
parent c7c95a757e
commit f6176e6357

View file

@ -9,12 +9,15 @@ end
local function regen_all() local function regen_all()
for _, player in pairs(minetest.get_connected_players()) do for _, player in pairs(minetest.get_connected_players()) do
local newhp = player:get_hp() + regen_amount local oldhp = player:get_hp()
if oldhp > 0 then
local newhp = oldhp + regen_amount
if newhp > 20 then if newhp > 20 then
newhp = 20 newhp = 20
end end
player:set_hp(newhp) player:set_hp(newhp)
end end
end
minetest.after(regen_interval, regen_all) minetest.after(regen_interval, regen_all)
end end
minetest.after(regen_interval, regen_all) minetest.after(regen_interval, regen_all)