diff options
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/builtin.lua | 1 | ||||
-rw-r--r-- | builtin/deprecated.lua | 3 | ||||
-rw-r--r-- | builtin/detached_inventory.lua | 19 | ||||
-rw-r--r-- | builtin/item.lua | 35 |
4 files changed, 23 insertions, 35 deletions
diff --git a/builtin/builtin.lua b/builtin/builtin.lua index bd5adf9e7..a17841fc8 100644 --- a/builtin/builtin.lua +++ b/builtin/builtin.lua @@ -21,4 +21,5 @@ dofile(minetest.get_modpath("__builtin").."/privileges.lua") dofile(minetest.get_modpath("__builtin").."/auth.lua") dofile(minetest.get_modpath("__builtin").."/chatcommands.lua") dofile(minetest.get_modpath("__builtin").."/static_spawn.lua") +dofile(minetest.get_modpath("__builtin").."/detached_inventory.lua") diff --git a/builtin/deprecated.lua b/builtin/deprecated.lua index 67210d525..d41e2c44c 100644 --- a/builtin/deprecated.lua +++ b/builtin/deprecated.lua @@ -16,4 +16,7 @@ minetest.digprop_woodlike = digprop_err minetest.digprop_leaveslike = digprop_err minetest.digprop_glasslike = digprop_err +minetest.node_metadata_inventory_move_allow_all = function() + minetest.log("info", "WARNING: minetest.node_metadata_inventory_move_allow_all is obsolete and does nothing.") +end diff --git a/builtin/detached_inventory.lua b/builtin/detached_inventory.lua new file mode 100644 index 000000000..3757f1387 --- /dev/null +++ b/builtin/detached_inventory.lua @@ -0,0 +1,19 @@ +-- Minetest: builtin/detached_inventory.lua + +minetest.detached_inventories = {} + +function minetest.create_detached_inventory(name, callbacks) + local stuff = {} + stuff.name = name + if callbacks then + stuff.allow_move = callbacks.allow_move + stuff.allow_put = callbacks.allow_put + stuff.allow_take = callbacks.allow_take + stuff.on_move = callbacks.on_move + stuff.on_put = callbacks.on_put + stuff.on_take = callbacks.on_take + end + minetest.detached_inventories[name] = stuff + return minetest.create_detached_inventory_raw(name) +end + diff --git a/builtin/item.lua b/builtin/item.lua index bd34efe79..2a9b4ff27 100644 --- a/builtin/item.lua +++ b/builtin/item.lua @@ -318,41 +318,6 @@ 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 -- NOTE: This is not the preferred way. Preferred way is to provide enough -- callbacks to not require redefining global functions. -celeron55 |