detached_inventory.lua 739 B

123456789101112131415161718192021222324
  1. -- Minetest: builtin/detached_inventory.lua
  2. core.detached_inventories = {}
  3. function core.create_detached_inventory(name, callbacks, player_name)
  4. local stuff = {}
  5. stuff.name = name
  6. if callbacks then
  7. stuff.allow_move = callbacks.allow_move
  8. stuff.allow_put = callbacks.allow_put
  9. stuff.allow_take = callbacks.allow_take
  10. stuff.on_move = callbacks.on_move
  11. stuff.on_put = callbacks.on_put
  12. stuff.on_take = callbacks.on_take
  13. end
  14. stuff.mod_origin = core.get_current_modname() or "??"
  15. core.detached_inventories[name] = stuff
  16. return core.create_detached_inventory_raw(name, player_name)
  17. end
  18. function core.remove_detached_inventory(name)
  19. core.detached_inventories[name] = nil
  20. return core.remove_detached_inventory_raw(name)
  21. end