aboutsummaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2012-07-25 02:36:54 +0300
committerPerttu Ahola <celeron55@gmail.com>2012-07-25 02:36:54 +0300
commit9eaf93d41d6745b877f8f52cf54b21050abefda1 (patch)
tree5ceebc9b208a415a01440f60605345f5c238cae2 /builtin
parent2ac20982e0772b94b21d95b53519bd2164632d98 (diff)
downloadminetest-9eaf93d41d6745b877f8f52cf54b21050abefda1.tar.gz
minetest-9eaf93d41d6745b877f8f52cf54b21050abefda1.tar.bz2
minetest-9eaf93d41d6745b877f8f52cf54b21050abefda1.zip
Detached inventory callbacks and reworked node metadata callbacks
Diffstat (limited to 'builtin')
-rw-r--r--builtin/builtin.lua1
-rw-r--r--builtin/deprecated.lua3
-rw-r--r--builtin/detached_inventory.lua19
-rw-r--r--builtin/item.lua35
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