^ Ignite TNT at position
+
+To make dropping items from node inventories easier, you can use the
+following helper function from 'default':
+
+default.get_inventory_drops(pos, inventory, drops)
+
+^ Return drops from node inventory "inventory" in drops.
+
+* `pos` - the node position
+* `inventory` - the name of the inventory (string)
+* `drops` - an initialized list
+
+The function returns no values. The drops are returned in the `drops`
+parameter, and drops is not reinitialized so you can call it several
+times in a row to add more inventory items to it.
+
+
Screwdriver API
---------------
return true
end
end,
+ on_blast = function(pos)
+ end,
})
local function may_replace(pos, player)
})
+--
+-- optimized helper to put all items in an inventory into a drops list
+--
+function default.get_inventory_drops(pos, inventory, drops)
+ local inv = minetest.get_meta(pos):get_inventory()
+ local n = #drops
+ for i = 1, inv:get_size(inventory) do
+ local stack = inv:get_stack(inventory, i)
+ if stack:get_count() > 0 then
+ drops[n+1] = stack:to_table()
+ n = n + 1
+ end
+ end
+end
+
--
-- Papyrus and cactus growing
--
local timer = minetest.get_node_timer(pos)
timer:start(1.0)
end,
+ on_blast = function(pos)
+ local drops = {}
+ default.get_inventory_drops(pos, "src", drops)
+ default.get_inventory_drops(pos, "fuel", drops)
+ default.get_inventory_drops(pos, "dst", drops)
+ drops[#drops+1] = "default:furnace"
+ minetest.remove_node(pos)
+ return drops
+ end,
allow_metadata_inventory_put = allow_metadata_inventory_put,
allow_metadata_inventory_move = allow_metadata_inventory_move,
" takes " .. stack:get_name() ..
" from chest at " .. minetest.pos_to_string(pos))
end,
+ on_blast = function(pos)
+ local drops = {}
+ default.get_inventory_drops(pos, "main", drops)
+ drops[#drops+1] = "default:chest"
+ minetest.remove_node(pos)
+ return drops
+ end,
})
minetest.register_node("default:chest_locked", {
minetest.log("action", player:get_player_name() ..
" takes stuff from bookshelf at " .. minetest.pos_to_string(pos))
end,
+ on_blast = function(pos)
+ local drops = {}
+ default.get_inventory_drops(pos, "books", drops)
+ drops[#drops+1] = "default:bookshelf"
+ minetest.remove_node(pos)
+ return drops
+ end,
})
local function register_sign(material, desc, def)
item:get_count(),
item:get_stack_max()))
rand_pos(pos, drop_pos, radius)
- local obj = minetest.add_item(drop_pos, item:get_name() .. " " .. take)
+ local dropitem = ItemStack(item)
+ dropitem:set_count(take)
+ local obj = minetest.add_item(drop_pos, dropitem)
if obj then
obj:get_luaentity().collect = true
obj:setacceleration({x = 0, y = -10, z = 0})
minetest.log("action", player:get_player_name() ..
" takes stuff from vessels shelf at ".. minetest.pos_to_string(pos))
end,
+ on_blast = function(pos)
+ local drops = {}
+ default.get_inventory_drops(pos, "vessels", drops)
+ drops[#drops+1] = "vessels:shelf"
+ minetest.remove_node(pos)
+ return drops
+ end,
})
minetest.register_craft({