init.lua 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. sounds = default.node_sound_stone_defaults(),
  26. mesecons = {receptor = {
  27. state = mesecon.state.off
  28. }}
  29. })
  30. minetest.register_node("mesecons_hydroturbine:hydro_turbine_on", {
  31. drawtype = "nodebox",
  32. tiles = {"jeija_hydro_turbine_on.png"},
  33. drop = "mesecons_hydroturbine:hydro_turbine_off 1",
  34. groups = {dig_immediate=2,not_in_creative_inventory=1},
  35. description="Water Turbine",
  36. paramtype = "light",
  37. selection_box = {
  38. type = "fixed",
  39. fixed = {{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
  40. {-0.15, 0.5, -0.15, 0.15, 1.45, 0.15},
  41. {-0.5, 1.15, -0.1, 0.5, 1.45, 0.1},
  42. {-0.1, 1.15, -0.5, 0.1, 1.45, 0.5}},
  43. },
  44. node_box = {
  45. type = "fixed",
  46. fixed = {{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
  47. {-0.15, 0.5, -0.15, 0.15, 1.45, 0.15},
  48. {-0.5, 1.15, -0.1, 0.5, 1.45, 0.1},
  49. {-0.1, 1.15, -0.5, 0.1, 1.45, 0.5}},
  50. },
  51. sounds = default.node_sound_stone_defaults(),
  52. mesecons = {receptor = {
  53. state = mesecon.state.on
  54. }}
  55. })
  56. minetest.register_abm({
  57. nodenames = {"mesecons_hydroturbine:hydro_turbine_off"},
  58. interval = 1,
  59. chance = 1,
  60. action = function(pos, node, active_object_count, active_object_count_wider)
  61. local waterpos={x=pos.x, y=pos.y+1, z=pos.z}
  62. if minetest.env:get_node(waterpos).name=="default:water_flowing" then
  63. minetest.env:add_node(pos, {name="mesecons_hydroturbine:hydro_turbine_on"})
  64. nodeupdate(pos)
  65. mesecon:receptor_on(pos)
  66. end
  67. end,
  68. })
  69. minetest.register_abm({
  70. nodenames = {"mesecons_hydroturbine:hydro_turbine_on"},
  71. interval = 1,
  72. chance = 1,
  73. action = function(pos, node, active_object_count, active_object_count_wider)
  74. local waterpos={x=pos.x, y=pos.y+1, z=pos.z}
  75. if minetest.env:get_node(waterpos).name~="default:water_flowing" then
  76. minetest.env:add_node(pos, {name="mesecons_hydroturbine:hydro_turbine_off"})
  77. nodeupdate(pos)
  78. mesecon:receptor_off(pos)
  79. end
  80. end,
  81. })
  82. minetest.register_craft({
  83. output = "mesecons_hydroturbine:hydro_turbine_off 2",
  84. recipe = {
  85. {"","default:stick", ""},
  86. {"default:stick", "default:steel_ingot", "default:stick"},
  87. {"","default:stick", ""},
  88. }
  89. })