mirror of
https://github.com/minetest-mods/3d_armor.git
synced 2024-11-22 20:43:43 +01:00
Only allow one of each armor element in armor slots
Required, otherwise equip callbacks may be bogus.
This commit is contained in:
parent
75a7181e0f
commit
6bf28dc2c5
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user