mirror of
https://github.com/minetest-mods/drawers.git
synced 2024-11-22 14:43:45 +01:00
Adapt drop function for 2x2 drawers to drop *all* items
This commit is contained in:
parent
d3d29fb497
commit
69a974cb6b
23
lua/api.lua
23
lua/api.lua
@ -77,12 +77,20 @@ end
|
|||||||
|
|
||||||
-- drop all items
|
-- drop all items
|
||||||
function drawers.drawer_on_dig(pos, node, player)
|
function drawers.drawer_on_dig(pos, node, player)
|
||||||
local meta = core.get_meta(pos)
|
local drawerType = 1
|
||||||
local count = meta:get_int("count")
|
if core.registered_nodes[node.name] then
|
||||||
local name = meta:get_string("name")
|
drawerType = core.registered_nodes[node.name].groups.drawer
|
||||||
|
end
|
||||||
|
|
||||||
-- remove node
|
local meta = core.get_meta(pos)
|
||||||
core.node_dig(pos, node, player)
|
|
||||||
|
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
|
-- drop the items
|
||||||
local stack_max = ItemStack(name):get_stack_max()
|
local stack_max = ItemStack(name):get_stack_max()
|
||||||
@ -97,6 +105,11 @@ function drawers.drawer_on_dig(pos, node, player)
|
|||||||
end
|
end
|
||||||
i = i + 1
|
i = i + 1
|
||||||
end
|
end
|
||||||
|
k = k + 1
|
||||||
|
end
|
||||||
|
|
||||||
|
-- remove node
|
||||||
|
core.node_dig(pos, node, player)
|
||||||
end
|
end
|
||||||
|
|
||||||
function drawers.drawer_insert_object(pos, node, stack, direction)
|
function drawers.drawer_insert_object(pos, node, stack, direction)
|
||||||
|
Loading…
Reference in New Issue
Block a user