detached_inventory.lua 959 B

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