vacuum.lua 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. minetest.register_node("factory:vacuum_on", {
  2. description = "Vacuum",
  3. tiles = {"factory_machine_steel_dark.png^factory_ring_green.png", "factory_machine_steel_dark.png^factory_8x8_black_square_32x32.png", "factory_machine_steel_dark.png",
  4. "factory_machine_steel_dark.png", "factory_machine_steel_dark.png", "factory_machine_steel_dark.png"},
  5. groups = {cracky=2},
  6. drawtype = "nodebox",
  7. paramtype = "light",
  8. paramtype2 = "facedir",
  9. is_ground_content = true,
  10. legacy_facedir_simple = true,
  11. node_box = {
  12. type = "fixed",
  13. fixed = {{-0.25, 0.3125, -0.25, 0.25, 0.375, 0.25},
  14. {-0.3125, 0.4375, -0.375, 0.3125, 0.5, -0.3125},
  15. {-0.3125, 0.4375, 0.3125, 0.3125, 0.5, 0.375},
  16. {0.3125, 0.4375, -0.375, 0.375, 0.5, 0.375},
  17. {-0.375, 0.4375, -0.375, -0.3125, 0.5, 0.375},
  18. {-0.3125, 0.375, 0.25, 0.3125, 0.4375, 0.3125},
  19. {-0.3125, 0.375, -0.3125, 0.3125, 0.4375, -0.25},
  20. {0.25, 0.375, -0.25, 0.3125, 0.4375, 0.25},
  21. {-0.3125, 0.375, -0.25, -0.25, 0.4375, 0.25},
  22. {-0.25, 0.375, 0.3125, -0.1875, 0.4375, 0.5},
  23. {0.1875, 0.375, 0.25, 0.25, 0.4375, 0.5},
  24. {-0.25, 0.375, -0.5, -0.1875, 0.4375, -0.3125},
  25. {0.1875, 0.375, -0.5, 0.25, 0.4375, -0.3125},
  26. {0.3125, 0.375, -0.25, 0.5, 0.4375, -0.1875},
  27. {0.3125, 0.375, 0.1875, 0.5, 0.4375, 0.25},
  28. {-0.5, 0.375, 0.1875, -0.3125, 0.4375, 0.25},
  29. {-0.5, 0.375, -0.25, -0.3125, 0.4375, -0.1875},
  30. {-0.125, -0.4375, -0.125, 0.125, 0.3125, 0.125},
  31. {-0.125, 0, -0.1875, 0.1875, 0.0625, -0.125},
  32. {0.125, 0.0625, -0.1875, 0.1875, 0.25, -0.125},
  33. {0.125, 0.1875, -0.25, 0.1875, 0.3125, -0.1875},
  34. {0.125, 0, -0.1875, 0.1875, 0.0625, 0.125},
  35. {-0.125, -0.375, -0.1875, -0.0625, 0, -0.125},}
  36. },
  37. selection_box = {
  38. type = "fixed",
  39. fixed = {
  40. {-0.5,-0.5,-0.5,0.5,0.5,0.5},
  41. }
  42. },
  43. on_rightclick = function(pos, node, player, itemstack, pointed_thing)
  44. minetest.swap_node(pos, {name = "factory:vacuum_off", param2 = node.param2})
  45. end,
  46. })
  47. minetest.register_node("factory:vacuum_off", {
  48. description = "Vacuum",
  49. tiles = {"factory_machine_steel_dark.png^factory_ring_red.png", "factory_machine_steel_dark.png^factory_8x8_black_square_32x32.png", "factory_machine_steel_dark.png",
  50. "factory_machine_steel_dark.png", "factory_machine_steel_dark.png", "factory_machine_steel_dark.png"},
  51. groups = {cracky=2, not_in_creative_inventory = 1},
  52. drawtype = "nodebox",
  53. paramtype = "light",
  54. paramtype2 = "facedir",
  55. is_ground_content = true,
  56. legacy_facedir_simple = true,
  57. node_box = {
  58. type = "fixed",
  59. fixed = {{-0.25, 0.3125, -0.25, 0.25, 0.375, 0.25},
  60. {-0.3125, 0.4375, -0.375, 0.3125, 0.5, -0.3125},
  61. {-0.3125, 0.4375, 0.3125, 0.3125, 0.5, 0.375},
  62. {0.3125, 0.4375, -0.375, 0.375, 0.5, 0.375},
  63. {-0.375, 0.4375, -0.375, -0.3125, 0.5, 0.375},
  64. {-0.3125, 0.375, 0.25, 0.3125, 0.4375, 0.3125},
  65. {-0.3125, 0.375, -0.3125, 0.3125, 0.4375, -0.25},
  66. {0.25, 0.375, -0.25, 0.3125, 0.4375, 0.25},
  67. {-0.3125, 0.375, -0.25, -0.25, 0.4375, 0.25},
  68. {-0.25, 0.375, 0.3125, -0.1875, 0.4375, 0.5},
  69. {0.1875, 0.375, 0.25, 0.25, 0.4375, 0.5},
  70. {-0.25, 0.375, -0.5, -0.1875, 0.4375, -0.3125},
  71. {0.1875, 0.375, -0.5, 0.25, 0.4375, -0.3125},
  72. {0.3125, 0.375, -0.25, 0.5, 0.4375, -0.1875},
  73. {0.3125, 0.375, 0.1875, 0.5, 0.4375, 0.25},
  74. {-0.5, 0.375, 0.1875, -0.3125, 0.4375, 0.25},
  75. {-0.5, 0.375, -0.25, -0.3125, 0.4375, -0.1875},
  76. {-0.125, -0.4375, -0.125, 0.125, 0.3125, 0.125},
  77. {-0.125, 0, -0.1875, 0.1875, 0.0625, -0.125},
  78. {0.125, 0.0625, -0.1875, 0.1875, 0.25, -0.125},
  79. {0.125, 0.1875, -0.25, 0.1875, 0.3125, -0.1875},
  80. {0.125, 0, -0.1875, 0.1875, 0.0625, 0.125},
  81. {-0.125, -0.375, -0.1875, -0.0625, 0, -0.125},}
  82. },
  83. selection_box = {
  84. type = "fixed",
  85. fixed = {
  86. {-0.5,-0.5,-0.5,0.5,0.5,0.5},
  87. }
  88. },
  89. on_rightclick = function(pos, node, player, itemstack, pointed_thing)
  90. minetest.swap_node(pos, {name = "factory:vacuum_on", param2 = node.param2})
  91. end,
  92. })
  93. minetest.register_abm({
  94. nodenames = {"factory:vacuum_on"},
  95. neighbors = nil,
  96. interval = 1,
  97. chance = 1,
  98. action = function(pos, node, active_object_count, active_object_count_wider)
  99. local all_objects = factory.get_objects_with_square_radius({x = pos.x, y = pos.y + 3, z = pos.z}, 2)
  100. local _,obj
  101. for _,obj in ipairs(all_objects) do
  102. if not obj:is_player() and obj:get_luaentity() and (obj:get_luaentity().name == "__builtin:item" or obj:get_luaentity().name == "factory:moving_item") then
  103. obj:moveto({x = pos.x, y = pos.y - 0.5, z = pos.z})
  104. end
  105. end
  106. end,
  107. })