init.lua 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. -- HYDRO_TURBINE
  2. -- Water turbine:
  3. -- Active if flowing >water< above it
  4. -- (does not work with other liquids)
  5. minetest.register_node("mesecons_hydroturbine:hydro_turbine_off", {
  6. drawtype = "nodebox",
  7. tiles = {"jeija_hydro_turbine_off.png"},
  8. groups = {dig_immediate=2},
  9. description="Water Turbine",
  10. paramtype = "light",
  11. selection_box = {
  12. type = "fixed",
  13. fixed = {{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
  14. {-0.15, 0.5, -0.15, 0.15, 1.45, 0.15},
  15. {-0.45, 1.15, -0.1, 0.45, 1.45, 0.1},
  16. {-0.1, 1.15, -0.45, 0.1, 1.45, 0.45}},
  17. },
  18. node_box = {
  19. type = "fixed",
  20. fixed = {{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
  21. {-0.15, 0.5, -0.15, 0.15, 1.45, 0.15},
  22. {-0.45, 1.15, -0.1, 0.45, 1.45, 0.1},
  23. {-0.1, 1.15, -0.45, 0.1, 1.45, 0.45}},
  24. },
  25. mesecons = {receptor = {
  26. state = mesecon.state.off
  27. }}
  28. })
  29. minetest.register_node("mesecons_hydroturbine:hydro_turbine_on", {
  30. drawtype = "nodebox",
  31. tiles = {"jeija_hydro_turbine_on.png"},
  32. drop = '"mesecons_hydroturbine:hydro_turbine_off" 1',
  33. groups = {dig_immediate=2,not_in_creative_inventory=1},
  34. description="Water Turbine",
  35. paramtype = "light",
  36. selection_box = {
  37. type = "fixed",
  38. fixed = {{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
  39. {-0.15, 0.5, -0.15, 0.15, 1.45, 0.15},
  40. {-0.5, 1.15, -0.1, 0.5, 1.45, 0.1},
  41. {-0.1, 1.15, -0.5, 0.1, 1.45, 0.5}},
  42. },
  43. node_box = {
  44. type = "fixed",
  45. fixed = {{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
  46. {-0.15, 0.5, -0.15, 0.15, 1.45, 0.15},
  47. {-0.5, 1.15, -0.1, 0.5, 1.45, 0.1},
  48. {-0.1, 1.15, -0.5, 0.1, 1.45, 0.5}},
  49. },
  50. mesecons = {receptor = {
  51. state = mesecon.state.on
  52. }}
  53. })
  54. minetest.register_abm({
  55. nodenames = {"mesecons_hydroturbine:hydro_turbine_off"},
  56. interval = 1,
  57. chance = 1,
  58. action = function(pos, node, active_object_count, active_object_count_wider)
  59. local waterpos={x=pos.x, y=pos.y+1, z=pos.z}
  60. if minetest.env:get_node(waterpos).name=="default:water_flowing" then
  61. minetest.env:add_node(pos, {name="mesecons_hydroturbine:hydro_turbine_on"})
  62. nodeupdate(pos)
  63. mesecon:receptor_on(pos)
  64. end
  65. end,
  66. })
  67. minetest.register_abm({
  68. nodenames = {"mesecons_hydroturbine:hydro_turbine_on"},
  69. interval = 1,
  70. chance = 1,
  71. action = function(pos, node, active_object_count, active_object_count_wider)
  72. local waterpos={x=pos.x, y=pos.y+1, z=pos.z}
  73. if minetest.env:get_node(waterpos).name~="default:water_flowing" then
  74. minetest.env:add_node(pos, {name="mesecons_hydroturbine:hydro_turbine_off"})
  75. nodeupdate(pos)
  76. mesecon:receptor_off(pos)
  77. end
  78. end,
  79. })
  80. minetest.register_craft({
  81. output = '"mesecons_hydroturbine:hydro_turbine_off" 2',
  82. recipe = {
  83. {'','"default:stick"', ''},
  84. {'"default:stick"', '"default:steel_ingot"', '"default:stick"'},
  85. {'','"default:stick"', ''},
  86. }
  87. })