detached.lua 1.1 KB

1234567891011121314151617181920212223242526272829
  1. -- Create a detached inventory
  2. local inv = minetest.create_detached_inventory("test_inventory", {
  3. allow_move = function(inv, from_list, from_index, to_list, to_index, count, player)
  4. experimental.print_to_everything("allow move asked")
  5. return count -- Allow all
  6. end,
  7. allow_put = function(inv, listname, index, stack, player)
  8. experimental.print_to_everything("allow put asked")
  9. return 1 -- Allow only 1
  10. end,
  11. allow_take = function(inv, listname, index, stack, player)
  12. experimental.print_to_everything("allow take asked")
  13. return 4 -- Allow 4 at max
  14. end,
  15. on_move = function(inv, from_list, from_index, to_list, to_index, count, player)
  16. experimental.print_to_everything(player:get_player_name().." moved items")
  17. end,
  18. on_put = function(inv, listname, index, stack, player)
  19. experimental.print_to_everything(player:get_player_name().." put items")
  20. end,
  21. on_take = function(inv, listname, index, stack, player)
  22. experimental.print_to_everything(player:get_player_name().." took items")
  23. end,
  24. })
  25. inv:set_size("main", 4*6)
  26. inv:add_item("main", "experimental:callback_node")
  27. inv:add_item("main", "experimental:particle_spawner")