Add workaround to prevent "swapping" items into team chest (#645)

This commit is contained in:
LoneWolfHT 2020-05-22 18:37:54 -07:00 committed by ANAND
parent f37b8fb49e
commit e2ac380985
No known key found for this signature in database
GPG key ID: 3AD8A3C4A51AAB97

View file

@ -214,6 +214,14 @@ for _, chest_color in pairs(colors) do
end end
function def.on_metadata_inventory_take(pos, listname, index, stack, player) function def.on_metadata_inventory_take(pos, listname, index, stack, player)
local chestinv = minetest.get_inventory({type = "node", pos = pos})
local swapped_item = chestinv:get_stack(listname, index)
if not ctf_map.is_item_allowed_in_team_chest(listname, swapped_item, player) then
chestinv:remove_item(listname, swapped_item)
player:get_inventory():add_item(listname, swapped_item)
end
minetest.log("action", player:get_player_name() .. minetest.log("action", player:get_player_name() ..
" takes " .. (stack:get_name() or "stuff") .. " " .. " takes " .. (stack:get_name() or "stuff") .. " " ..
(stack:get_count() or 0) .. " from chest at " .. (stack:get_count() or 0) .. " from chest at " ..