mirror of
https://github.com/minetest-mods/drawers.git
synced 2024-11-26 08:33:45 +01:00
Drop all items on dug
This commit is contained in:
parent
4c3dd28fcd
commit
fe0daf9bdc
20
init.lua
20
init.lua
@ -304,8 +304,26 @@ end
|
|||||||
|
|
||||||
-- drop all items
|
-- drop all items
|
||||||
local function drawer_on_dig(pos, node, player)
|
local function drawer_on_dig(pos, node, player)
|
||||||
|
local meta = core.get_meta(pos)
|
||||||
|
local count = meta:get_int("count")
|
||||||
|
local name = meta:get_string("name")
|
||||||
|
|
||||||
|
-- remove node
|
||||||
core.node_dig(pos, node, player)
|
core.node_dig(pos, node, player)
|
||||||
return
|
|
||||||
|
-- drop the items
|
||||||
|
local stack_max = ItemStack(name):get_stack_max()
|
||||||
|
|
||||||
|
local j = math.floor(count / stack_max) + 1
|
||||||
|
local i = 1
|
||||||
|
while i <= j do
|
||||||
|
if not (i == j) then
|
||||||
|
core.add_item(pos, name .. " " .. stack_max)
|
||||||
|
else
|
||||||
|
core.add_item(pos, name .. " " .. count % stack_max)
|
||||||
|
end
|
||||||
|
i = i + 1
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function drawers.register_drawer(name, def)
|
function drawers.register_drawer(name, def)
|
||||||
|
Loading…
Reference in New Issue
Block a user