Check that hp is less than hp_max when trying to heal (#44)

This commit is contained in:
fluxionary 2023-03-18 00:53:50 -07:00 committed by GitHub
parent 1b767e820b
commit 78be994cab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -377,12 +377,14 @@ local function health_tick()
for _,player in ipairs(minetest.get_connected_players()) do
local air = player:get_breath() or 0
local hp = player:get_hp()
local hp_max = player:get_properties().hp_max
local saturation = stamina.get_saturation(player)
-- don't heal if dead, drowning, or poisoned
local should_heal = (
saturation >= settings.heal_lvl and
saturation >= hp and
hp < hp_max and
hp > 0 and
air > 0
and not stamina.is_poisoned(player)