aboutsummaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2012-09-02 19:38:44 +0300
committerPerttu Ahola <celeron55@gmail.com>2012-09-02 19:38:44 +0300
commitd53a6cd8518edd025acdfc7878ede857867e507b (patch)
tree089ff99cd0e15b6da8ac73deb79b642b49615ebf /builtin
parentb6c12d2aa3f7f3f0faca86a0b20904e309c15179 (diff)
downloadminetest-d53a6cd8518edd025acdfc7878ede857867e507b.tar.gz
minetest-d53a6cd8518edd025acdfc7878ede857867e507b.tar.bz2
minetest-d53a6cd8518edd025acdfc7878ede857867e507b.zip
Add overridable function for handling dropped items from nodes
Diffstat (limited to 'builtin')
-rw-r--r--builtin/item.lua21
1 files changed, 13 insertions, 8 deletions
diff --git a/builtin/item.lua b/builtin/item.lua
index 4e3c74444..0f8dcff1f 100644
--- a/builtin/item.lua
+++ b/builtin/item.lua
@@ -260,6 +260,16 @@ function minetest.node_punch(pos, node, puncher)
end
end
+function minetest.handle_node_drops(pos, drops, digger)
+ -- Add dropped items to object's inventory
+ if digger:get_inventory() then
+ local _, dropped_item
+ for _, dropped_item in ipairs(drops) do
+ digger:get_inventory():add_item("main", dropped_item)
+ end
+ end
+end
+
function minetest.node_dig(pos, node, digger)
minetest.debug("node_dig")
@@ -284,14 +294,9 @@ function minetest.node_dig(pos, node, digger)
local dp = minetest.get_dig_params(def.groups, tp)
wielded:add_wear(dp.wear)
digger:set_wielded_item(wielded)
-
- -- Add dropped items to object's inventory
- if digger:get_inventory() then
- local _, dropped_item
- for _, dropped_item in ipairs(drops) do
- digger:get_inventory():add_item("main", dropped_item)
- end
- end
+
+ -- Handle drops
+ minetest.handle_node_drops(pos, drops, digger)
local oldmetadata = nil
if def.after_dig_node then