From fd053e5c0bb7621eeafc2ebd3c8231172b5e8ee2 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 18 Feb 2017 22:36:04 +0100 Subject: [PATCH] Disallow to put non-armor items into armor slots --- .../minetest-3d_armor/3d_armor/armor.lua | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/mods/ITEMS/minetest-3d_armor/3d_armor/armor.lua b/mods/ITEMS/minetest-3d_armor/3d_armor/armor.lua index fb6f61bc..cc0a802a 100644 --- a/mods/ITEMS/minetest-3d_armor/3d_armor/armor.lua +++ b/mods/ITEMS/minetest-3d_armor/3d_armor/armor.lua @@ -389,13 +389,29 @@ minetest.register_on_joinplayer(function(player) armor:update_inventory(player) end, allow_put = function(inv, listname, index, stack, player) - return 1 + local iname = stack:get_name() + local g + local groupcheck + if index == 2 then + g = minetest.get_item_group(iname, "armor_head") + elseif index == 3 then + g = minetest.get_item_group(iname, "armor_torso") + elseif index == 4 then + g = minetest.get_item_group(iname, "armor_legs") + elseif index == 5 then + g = minetest.get_item_group(iname, "armor_feet") + end + if g ~= 0 and g ~= nil then + return stack:get_count() + else + return 0 + end end, allow_take = function(inv, listname, index, stack, player) return stack:get_count() end, allow_move = function(inv, from_list, from_index, to_list, to_index, count, player) - return count + return 0 end, }, name) if inv_mod == "inventory_plus" then