sorter wasn't checking allow_metadata_inventory_move

this allowed for items to be duplicated and destroyed inadvertently when
moving back and forth between the filter and the storage buffer
inventories.
This commit is contained in:
FaceDeer 2017-04-29 15:12:56 -06:00
parent 3f5deef63a
commit f871723edf

@ -126,6 +126,20 @@ minetest.register_node("hopper:sorter", {
return stack:get_count() return stack:get_count()
end, end,
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
if to_list == "filter" then
local inv = minetest.get_inventory({type="node", pos=pos})
local stack_moved = inv:get_stack(from_list, from_index)
inv:set_stack(to_list, to_index, stack_moved:take_item(1))
return 0
elseif from_list == "filter" then
local inv = minetest.get_inventory({type="node", pos=pos})
inv:set_stack(from_list, from_index, ItemStack(""))
return 0
end
return count
end,
on_metadata_inventory_put = function(pos, listname, index, stack, player) on_metadata_inventory_put = function(pos, listname, index, stack, player)
minetest.log("action", S("@1 moves stuff to sorter at @2", minetest.log("action", S("@1 moves stuff to sorter at @2",
player:get_player_name(), minetest.pos_to_string(pos))) player:get_player_name(), minetest.pos_to_string(pos)))