From 3ddcbae968c8ad8bf07762d86e6c46bc48fec795 Mon Sep 17 00:00:00 2001 From: Sirrobzeroone <44497598+sirrobzeroone@users.noreply.github.com> Date: Thu, 24 Dec 2020 13:11:06 +1100 Subject: [PATCH] Fix for #34 - Divide Armor Wear by # Pieces See Details contained in #34 Note1: I split out the fix for Issue 13 and it had been applied Note2: I will also do a seperate pull request for Issue 30 From what I udnerstand smaller specific pull requests allow for reversion of specific additions and features much more easily. Please do correct me if I have the wrong end of the stick on this. --- 3d_armor/api.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/3d_armor/api.lua b/3d_armor/api.lua index 38e9898..70cb584 100644 --- a/3d_armor/api.lua +++ b/3d_armor/api.lua @@ -416,6 +416,12 @@ end armor.damage = function(self, player, index, stack, use) local old_stack = ItemStack(stack) + local worn_armor = armor:get_weared_armor_elements(player) + local armor_worn_cnt = 0 + for k,v in pairs(worn_armor) do + armor_worn_cnt = armor_worn_cnt + 1 + end + use = math.ceil(use/armor_worn_cnt) stack:add_wear(use) self:run_callbacks("on_damage", player, index, stack) self:set_inventory_stack(player, index, stack)