water.lua 4.6 KB

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