aboutsummaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
Diffstat (limited to 'builtin')
-rw-r--r--builtin/item.lua41
1 files changed, 41 insertions, 0 deletions
diff --git a/builtin/item.lua b/builtin/item.lua
index d30b439aa..eb8c556de 100644
--- a/builtin/item.lua
+++ b/builtin/item.lua
@@ -262,6 +262,41 @@ function minetest.node_dig(pos, node, digger)
end
end
+function minetest.node_metadata_inventory_move_allow_all(pos, from_list,
+ from_index, to_list, to_index, count, player)
+ minetest.log("verbose", "node_metadata_inventory_move_allow_all")
+ local meta = minetest.env:get_meta(pos)
+ local inv = meta:get_inventory()
+
+ local from_stack = inv:get_stack(from_list, from_index)
+ local taken_items = from_stack:take_item(count)
+ inv:set_stack(from_list, from_index, from_stack)
+
+ local to_stack = inv:get_stack(to_list, to_index)
+ to_stack:add_item(taken_items)
+ inv:set_stack(to_list, to_index, to_stack)
+end
+
+function minetest.node_metadata_inventory_offer_allow_all(pos, listname, index, stack, player)
+ minetest.log("verbose", "node_metadata_inventory_offer_allow_all")
+ local meta = minetest.env:get_meta(pos)
+ local inv = meta:get_inventory()
+ local the_stack = inv:get_stack(listname, index)
+ the_stack:add_item(stack)
+ inv:set_stack(listname, index, the_stack)
+ return ItemStack("")
+end
+
+function minetest.node_metadata_inventory_take_allow_all(pos, listname, index, count, player)
+ minetest.log("verbose", "node_metadata_inventory_take_allow_all")
+ local meta = minetest.env:get_meta(pos)
+ local inv = meta:get_inventory()
+ local the_stack = inv:get_stack(listname, index)
+ local taken_items = the_stack:take_item(count)
+ inv:set_stack(listname, index, the_stack)
+ return taken_items
+end
+
-- This is used to allow mods to redefine minetest.item_place and so on
local function redef_wrapper(table, name)
return function(...)
@@ -295,6 +330,12 @@ minetest.nodedef_default = {
on_punch = redef_wrapper(minetest, 'node_punch'), -- minetest.node_punch
on_dig = redef_wrapper(minetest, 'node_dig'), -- minetest.node_dig
+ on_receive_fields = nil,
+
+ on_metadata_inventory_move = minetest.node_metadata_inventory_move_allow_all,
+ on_metadata_inventory_offer = minetest.node_metadata_inventory_offer_allow_all,
+ on_metadata_inventory_take = minetest.node_metadata_inventory_take_allow_all,
+
-- Node properties
drawtype = "normal",
visual_scale = 1.0,