From 011ad09890439ef53a9eb893ffc9bf5d3003e46b Mon Sep 17 00:00:00 2001 From: Le_Docteur Date: Sun, 21 Jun 2015 11:44:04 +0200 Subject: [PATCH] Full health restoration for the dog. --- mods/mobs/dog.lua | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/mods/mobs/dog.lua b/mods/mobs/dog.lua index fd8e2d21..4f9e2eaa 100755 --- a/mods/mobs/dog.lua +++ b/mods/mobs/dog.lua @@ -39,12 +39,20 @@ mobs:register_mob("mobs:dog", { local item = clicker:get_wielded_item() if item:get_name() == "mobs:meat_raw" then local hp = self.object:get_hp() - if hp + 4 > self.hp_max then return end + -- return if full health + if hp >= self.hp_max then + minetest.chat_send_player(name, "Dog at full health.") + return + end + hp = hp + 4 -- add restorative value + -- new health shouldn't exceed self.hp_max + if hp > self.hp_max then hp = self.hp_max end + self.object:set_hp(hp) + -- Take item if not minetest.setting_getbool("creative_mode") then item:take_item() clicker:set_wielded_item(item) end - self.object:set_hp(hp+4) else if self.owner == "" then self.owner = clicker:get_player_name()