inv.lua 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. function city_block.allow_metadata_inventory_move(pos, from_list, from_index, to_list, to_index, count, user)
  2. return 0
  3. end
  4. function city_block.on_metadata_inventory_move(pos, from_list, from_index, to_list, to_index, count, user)
  5. end
  6. function city_block.allow_metadata_inventory_put(pos, listname, index, stack, user)
  7. local pname = user:get_player_name()
  8. local context = city_block.formspecs[pname]
  9. -- Context should have been created in 'on_rightclick'. CSM protection.
  10. if not context then
  11. return 0
  12. end
  13. if listname == "config" and stack:get_name() == "cfg:dev" then
  14. local meta = minetest.get_meta(pos)
  15. local owner = meta:get_string("owner")
  16. local inv = meta:get_inventory()
  17. if inv:is_empty("config") and owner == pname then
  18. return 1
  19. end
  20. end
  21. return 0
  22. end
  23. function city_block.on_metadata_inventory_put(pos, listname, index, stack, user)
  24. end
  25. function city_block.allow_metadata_inventory_take(pos, listname, index, stack, user)
  26. local pname = user:get_player_name()
  27. local context = city_block.formspecs[pname]
  28. -- Context should have been created in 'on_rightclick'. CSM protection.
  29. if not context then
  30. return 0
  31. end
  32. if listname == "config" then
  33. local meta = minetest.get_meta(pos)
  34. local owner = meta:get_string("owner")
  35. if owner == pname then
  36. return stack:get_count()
  37. end
  38. end
  39. return 0
  40. end
  41. function city_block.on_metadata_inventory_take(pos, listname, index, stack, user)
  42. end