1
0
mirror of https://github.com/minetest-mods/3d_armor.git synced 2025-06-29 23:00:55 +02:00

Validate and clean armor inventory before saving

This commit is contained in:
stujones11
2018-05-19 20:25:27 +01:00
parent 21716ffd31
commit 21b5c68505
2 changed files with 38 additions and 36 deletions

View File

@ -132,19 +132,18 @@ local function init_player_armor(player)
end,
allow_put = function(inv, listname, index, stack, player)
local def = stack:get_definition() or {}
local allowed = 0
for _, element in pairs(armor.elements) do
local element = armor:get_element(stack:get_name())
if not element then
return 0
end
for i = 1, 6 do
local stack = inv:get_stack("armor", i)
local def = stack:get_definition() or {}
if def.groups["armor_"..element] then
allowed = 1
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
return 0
end
end
return allowed
return 1
end,
allow_take = function(inv, listname, index, stack, player)
return stack:get_count()