From 6bf28dc2c56911ea029a19a05185cef3df1c86fb Mon Sep 17 00:00:00 2001 From: stujones11 Date: Sat, 18 Mar 2017 20:27:39 +0000 Subject: [PATCH] Only allow one of each armor element in armor slots Required, otherwise equip callbacks may be bogus. --- 3d_armor/init.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/3d_armor/init.lua b/3d_armor/init.lua index 2312841..767453f 100644 --- a/3d_armor/init.lua +++ b/3d_armor/init.lua @@ -208,6 +208,17 @@ minetest.register_on_joinplayer(function(player) armor:update_inventory(player) end, allow_put = function(inv, listname, index, stack, player) + local def = stack:get_definition() or {} + for _, element in pairs(armor.elements) do + if def.groups["armor_"..element] then + for i = 1, 6 do + local item = inv:get_stack("armor", i):get_name() + if minetest.get_item_group(item, "armor_"..element) > 0 then + return 0 + end + end + end + end return 1 end, allow_take = function(inv, listname, index, stack, player)