detached_inventory.lua 914 B

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