Skip to content

Commit

Permalink
Change group to 'choppy'.
Browse files Browse the repository at this point in the history
Add support to include shelf as drop on blast and on dig
  • Loading branch information
hkzorman committed Feb 7, 2018
1 parent cc0db46 commit 00f97ee
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ function itemshelf.register_shelf(name, def)
drawtype = drawtype,
node_box = def.nodebox,
mesh = def.mesh,
groups = {cracky = 2, itemshelf = 1, itemshelf_shown_items = def.shown_items or 4},
groups = {choppy = 2, itemshelf = 1, itemshelf_shown_items = def.shown_items or 4},
on_construct = function(pos)
-- Initialize inventory
local meta = minetest.get_meta(pos)
Expand Down Expand Up @@ -195,7 +195,8 @@ function itemshelf.register_shelf(name, def)
for _,obj in pairs(objs) do
obj:remove()
end
-- Pop-up disc if existing
-- Pop-up items
minetest.add_item(pos, node.name)
local meta = minetest.get_meta(pos)
local list = meta:get_inventory():get_list("main")
for _,item in pairs(list) do
Expand All @@ -209,11 +210,19 @@ function itemshelf.register_shelf(name, def)
minetest.remove_node(pos)
end,
on_blast = function(pos)
local drops = {}
default.get_inventory_drops(pos, "itemshelf:shelf", drops)
drops[#drops + 1] = "itemshelf:shelf"
minetest.add_item(pos, minetest.get_node(pos).name)
local meta = minetest.get_meta(pos)
local list = meta:get_inventory():get_list("main")
for _,item in pairs(list) do
local drop_pos = {
x=math.random(pos.x - 0.5, pos.x + 0.5),
y=pos.y,
z=math.random(pos.z - 0.5, pos.z + 0.5)}
minetest.add_item(pos, item:get_name())
end
-- Remove node
minetest.remove_node(pos)
return drops
return nil
end,
-- Screwdriver support
on_rotate = function(pos, node, user, mode, new_param2) --{name = node.name, param1 = node.param1, param2 = node.param2}, user, mode, new_param2)
Expand Down

0 comments on commit 00f97ee

Please sign in to comment.