From a6b89e792962a48837cb56e3e11c8f999375a9ec Mon Sep 17 00:00:00 2001 From: orbea Date: Wed, 29 Apr 2020 00:24:46 -0700 Subject: [PATCH] Fix count when armor is destroyed. --- 3d_armor/api.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/3d_armor/api.lua b/3d_armor/api.lua index ed944b4..6a279ed 100644 --- a/3d_armor/api.lua +++ b/3d_armor/api.lua @@ -316,6 +316,8 @@ armor.punch = function(self, player, hitter, time_from_last_punch, tool_capabili if not name then return end + local set_state + local set_count local state = 0 local count = 0 local recip = true @@ -376,11 +378,17 @@ armor.punch = function(self, player, hitter, time_from_last_punch, tool_capabili end if damage == true then self:damage(player, i, stack, use) + set_state = self.def[name].state + set_count = self.def[name].count end state = state + stack:get_wear() count = count + 1 end end + if set_count and set_count ~= count then + state = set_state or state + count = set_count or count + end self.def[name].state = state self.def[name].count = count end