hopper.lua 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. function get_hopper_formspec()
  2. return "size[8,8.5]"..
  3. default.gui_bg..
  4. default.gui_bg_img..
  5. default.gui_slots..
  6. -- "list[context;src;2.75,0.5;1,1;]"..
  7. "list[context;main;0,1;8,2;]"..
  8. -- "list[context;dst;4.75,0.96;2,2;]"..
  9. "list[current_player;main;0,4.25;8,1;]"..
  10. "list[current_player;main;0,5.5;8,3;8]"..
  11. "listring[context;main]"..
  12. "listring[current_player;main]"..
  13. default.get_hotbar_bg(0, 4.25)
  14. end
  15. minetest.register_node("machines:hopper", {
  16. description = "Hopper",
  17. tiles = { "default_tin_block.png" },
  18. paramtype2 = "facedir",
  19. groups = {cracky=2},
  20. legacy_facedir_simple = true,
  21. is_ground_content = false,
  22. sounds = default.node_sound_stone_defaults(),
  23. stack_max = 1,
  24. can_dig = can_dig,
  25. on_construct = function(pos)
  26. local meta = minetest.get_meta(pos)
  27. meta:set_string("formspec", get_hopper_formspec())
  28. local inv = meta:get_inventory()
  29. inv:set_size('main', 8)
  30. end,
  31. --[[
  32. on_metadata_inventory_move = function(pos)
  33. --minetest.get_node_timer(pos):start(1.0)
  34. end,
  35. on_metadata_inventory_put = function(pos)
  36. -- start timer function, it will sort out whether furnace can burn or not.
  37. --minetest.get_node_timer(pos):start(1.0)
  38. end,]]
  39. on_blast = function(pos)
  40. local drops = {}
  41. default.get_inventory_drops(pos, "main", drops)
  42. drops[#drops+1] = "machines:hopper"
  43. minetest.remove_node(pos)
  44. return drops
  45. end,
  46. -- allow_metadata_inventory_put = allow_metadata_inventory_put,
  47. -- allow_metadata_inventory_move = allow_metadata_inventory_move,
  48. -- allow_metadata_inventory_take = allow_metadata_inventory_take,
  49. })
  50. minetest.register_craft({
  51. output = 'machines:hopper',
  52. recipe = {
  53. {'default:tin_ingot', '', 'default:tin_ingot'},
  54. {'default:tin_ingot', '', 'default:tin_ingot'},
  55. {'', 'default:tin_ingot', ''},
  56. }
  57. })