From 06dec8f8651068ec0ec5c98015dc0a5f7b13ea86 Mon Sep 17 00:00:00 2001 From: Sokomine Date: Thu, 16 Mar 2023 18:16:43 +0100 Subject: [PATCH] don't show formspec when fed with bread and already healed --- formspec.lua | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/formspec.lua b/formspec.lua index 3c964d9..3af8d54 100644 --- a/formspec.lua +++ b/formspec.lua @@ -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