Adapt drop function for 2x2 drawers to drop *all* items

This commit is contained in:
LNJ 2017-04-03 12:43:16 +02:00
parent d3d29fb497
commit 69a974cb6b
No known key found for this signature in database
GPG Key ID: 69268DBD835B6B0B

@ -77,12 +77,20 @@ end
-- drop all items
function drawers.drawer_on_dig(pos, node, player)
local meta = core.get_meta(pos)
local count = meta:get_int("count")
local name = meta:get_string("name")
local drawerType = 1
if core.registered_nodes[node.name] then
drawerType = core.registered_nodes[node.name].groups.drawer
end
-- remove node
core.node_dig(pos, node, player)
local meta = core.get_meta(pos)
k = 1
while k <= drawerType do
-- don't add a number in meta fields for 1x1 drawers
local vid = tostring(k)
if drawerType == 1 then vid = "" end
local count = meta:get_int("count"..vid)
local name = meta:get_string("name"..vid)
-- drop the items
local stack_max = ItemStack(name):get_stack_max()
@ -97,6 +105,11 @@ function drawers.drawer_on_dig(pos, node, player)
end
i = i + 1
end
k = k + 1
end
-- remove node
core.node_dig(pos, node, player)
end
function drawers.drawer_insert_object(pos, node, stack, direction)