don't show formspec when fed with bread and already healed

This commit is contained in:
Sokomine 2023-03-16 18:16:43 +01:00
parent a4c1828b7f
commit 06dec8f865

View File

@ -72,10 +72,12 @@ guards.on_rightclick = function(self, clicker)
-- heal with bread
local item = clicker:get_wielded_item()
if(item and item:get_name() == "farming:bread" and self.health < (self.hp_max or self.health)) then
item:take_item()
clicker:set_wielded_item(item)
self.health = math.min((self.hp_max or self.health), self.health + 10)
if(item and item:get_name() == "farming:bread") then
if(self.health < (self.hp_max or self.health)) then
item:take_item()
clicker:set_wielded_item(item)
self.health = math.min((self.hp_max or self.health), self.health + 10)
end
return
end