Fix hpregen whilst dead
This commit is contained in:
parent
c7c95a757e
commit
f6176e6357
1 changed files with 7 additions and 4 deletions
|
@ -9,11 +9,14 @@ 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 newhp > 20 then
|
if oldhp > 0 then
|
||||||
newhp = 20
|
local newhp = oldhp + regen_amount
|
||||||
|
if newhp > 20 then
|
||||||
|
newhp = 20
|
||||||
|
end
|
||||||
|
player:set_hp(newhp)
|
||||||
end
|
end
|
||||||
player:set_hp(newhp)
|
|
||||||
end
|
end
|
||||||
minetest.after(regen_interval, regen_all)
|
minetest.after(regen_interval, regen_all)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue