aboutsummaryrefslogtreecommitdiff
path: root/builtin/game/detached_inventory.lua
diff options
context:
space:
mode:
Diffstat (limited to 'builtin/game/detached_inventory.lua')
-rw-r--r--builtin/game/detached_inventory.lua24
1 files changed, 24 insertions, 0 deletions
diff --git a/builtin/game/detached_inventory.lua b/builtin/game/detached_inventory.lua
new file mode 100644
index 000000000..2e27168a1
--- /dev/null
+++ b/builtin/game/detached_inventory.lua
@@ -0,0 +1,24 @@
+-- Minetest: builtin/detached_inventory.lua
+
+core.detached_inventories = {}
+
+function core.create_detached_inventory(name, callbacks, player_name)
+ 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
+ stuff.mod_origin = core.get_current_modname() or "??"
+ core.detached_inventories[name] = stuff
+ return core.create_detached_inventory_raw(name, player_name)
+end
+
+function core.remove_detached_inventory(name)
+ core.detached_inventories[name] = nil
+ return core.remove_detached_inventory_raw(name)
+end