water.lua 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. local S = ethereal.intllib
  2. -- Ice Brick
  3. minetest.register_node("ethereal:icebrick", {
  4. description = S("Ice Brick"),
  5. tiles = {"ethereal_brick_ice.png"},
  6. paramtype = "light",
  7. is_ground_content = false,
  8. groups = {cracky = 3, puts_out_fire = 1, cools_lava = 1},
  9. sounds = default.node_sound_glass_defaults()
  10. })
  11. minetest.register_craft({
  12. output = "ethereal:icebrick 4",
  13. recipe = {
  14. {"default:ice", "default:ice"},
  15. {"default:ice", "default:ice"}
  16. }
  17. })
  18. -- Snow Brick
  19. minetest.register_node("ethereal:snowbrick", {
  20. description = S("Snow Brick"),
  21. tiles = {"ethereal_brick_snow.png"},
  22. paramtype = "light",
  23. is_ground_content = false,
  24. groups = {crumbly = 3, puts_out_fire = 1, cools_lava = 1},
  25. sounds = default.node_sound_dirt_defaults({
  26. footstep = {name = "default_snow_footstep", gain = 0.15},
  27. dug = {name = "default_snow_footstep", gain = 0.2},
  28. dig = {name = "default_snow_footstep", gain = 0.2}
  29. })
  30. })
  31. minetest.register_craft({
  32. output = "ethereal:snowbrick 4",
  33. recipe = {
  34. {"default:snowblock", "default:snowblock"},
  35. {"default:snowblock", "default:snowblock"}
  36. }
  37. })
  38. -- If Crystal Spike, Snow near Water, change Water to Ice
  39. minetest.register_abm({
  40. label = "Ethereal freeze water",
  41. nodenames = {
  42. "ethereal:crystal_spike", "default:snow", "default:snowblock",
  43. "ethereal:snowbrick"
  44. },
  45. neighbors = {"default:water_source", "default:river_water_source"},
  46. interval = 15,
  47. chance = 4,
  48. catch_up = false,
  49. action = function(pos, node)
  50. local near = minetest.find_node_near(pos, 1,
  51. {"default:water_source", "default:river_water_source"})
  52. if near then
  53. minetest.swap_node(near, {name = "default:ice"})
  54. end
  55. end,
  56. })
  57. -- If Heat Source near Ice or Snow then melt.
  58. minetest.register_abm({
  59. label = "Ethereal melt snow/ice",
  60. nodenames = {
  61. "default:ice", "default:snowblock", "default:snow",
  62. "default:dirt_with_snow", "ethereal:snowbrick", "ethereal:icebrick"
  63. },
  64. neighbors = {
  65. "fire:basic_flame", "default:lava_source", "default:lava_flowing",
  66. "default:furnace_active", "default:torch", "default:torch_wall",
  67. "default:torch_ceiling"
  68. },
  69. interval = 5,
  70. chance = 4,
  71. catch_up = false,
  72. action = function(pos, node)
  73. local water_node = "default:water"
  74. if pos.y > 2 then
  75. water_node = "default:river_water"
  76. end
  77. if node.name == "default:ice"
  78. or node.name == "default:snowblock"
  79. or node.name == "ethereal:icebrick"
  80. or node.name == "ethereal:snowbrick" then
  81. minetest.swap_node(pos, {name = water_node.."_source"})
  82. elseif node.name == "default:snow" then
  83. minetest.swap_node(pos, {name = water_node.."_flowing"})
  84. elseif node.name == "default:dirt_with_snow" then
  85. minetest.swap_node(pos, {name = "default:dirt_with_grass"})
  86. end
  87. ethereal.check_falling(pos)
  88. end,
  89. })
  90. -- If Water Source near Dry Dirt, change to normal Dirt
  91. minetest.register_abm({
  92. label = "Ethereal wet dry dirt",
  93. nodenames = {
  94. "ethereal:dry_dirt", "default:dirt_with_dry_grass",
  95. "default:dry_dirt", "default:dry_dirt_with_dry_grass"
  96. },
  97. neighbors = {"group:water"},
  98. interval = 15,
  99. chance = 2,
  100. catch_up = false,
  101. action = function(pos, node)
  102. if node.name == "ethereal:dry_dirt"
  103. or node.name == "default:dry_dirt" then
  104. minetest.swap_node(pos, {name = "default:dirt"})
  105. elseif node.name == "default:dirt_with_dry_grass" then
  106. minetest.swap_node(pos, {name = "default:dirt_with_grass"})
  107. else
  108. minetest.swap_node(pos, {name = "default:dirt_with_dry_grass"})
  109. end
  110. end
  111. })
  112. -- when enabled, drop torches that are touching water
  113. if ethereal.torchdrop == true and not minetest.get_modpath("real_torch") then
  114. minetest.register_abm({
  115. label = "Ethereal drop torch",
  116. nodenames = {"default:torch", "default:torch_wall", "default:torch_ceiling"},
  117. neighbors = {"group:water"},
  118. interval = 5,
  119. chance = 1,
  120. catch_up = false,
  121. action = function(pos, node)
  122. local num = #minetest.find_nodes_in_area(
  123. {x = pos.x - 1, y = pos.y, z = pos.z},
  124. {x = pos.x + 1, y = pos.y, z = pos.z},
  125. {"group:water"})
  126. if num == 0 then
  127. num = num + #minetest.find_nodes_in_area(
  128. {x = pos.x, y = pos.y, z = pos.z - 1},
  129. {x = pos.x, y = pos.y, z = pos.z + 1},
  130. {"group:water"})
  131. end
  132. if num == 0 then
  133. num = num + #minetest.find_nodes_in_area(
  134. {x = pos.x, y = pos.y + 1, z = pos.z},
  135. {x = pos.x, y = pos.y + 1, z = pos.z},
  136. {"group:water"})
  137. end
  138. if num > 0 then
  139. minetest.set_node(pos, {name = "air"})
  140. minetest.sound_play("fire_extinguish_flame",
  141. {pos = pos, gain = 0.2, max_hear_distance = 10})
  142. minetest.add_item(pos, {name = "default:torch"})
  143. end
  144. end
  145. })
  146. end