lava_cooling.lua 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. -- Renew mod for Minetest
  2. -- Copyright © 2018 Alex Yst <https://y.st./>
  3. -- This program is free software; you can redistribute it and/or
  4. -- modify it under the terms of the GNU Lesser General Public
  5. -- License as published by the Free Software Foundation; either
  6. -- version 2.1 of the License, or (at your option) any later version.
  7. -- This software is distributed in the hope that it will be useful,
  8. -- but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. -- Lesser General Public License for more details.
  11. -- You should have received a copy of the GNU Lesser General Public
  12. -- License along with this program. If not, see
  13. -- <https://www.gnu.org./licenses/>.
  14. local function spawn_coal(y)
  15. if y >= 1025 and y <= 31000 then
  16. if math.random(8 * 8 * 8) <= 9 then
  17. return true
  18. end
  19. end
  20. if y >= -31000 and y <= 64 then
  21. if math.random(8 * 8 * 8) <= 8 then
  22. return true
  23. end
  24. end
  25. if y >= -31000 and y <= 0 then
  26. if math.random(24 * 24 * 24) <= 27 then
  27. return true
  28. end
  29. end
  30. end
  31. local function spawn_iron(y)
  32. if y >= 1025 and y <= 31000 then
  33. if math.random(9 * 9 * 9) <= 12 then
  34. return true
  35. end
  36. end
  37. if y >= -31000 and y <= 0 then
  38. if math.random(7 * 7 * 7) <= 5 then
  39. return true
  40. end
  41. end
  42. if y >= -31000 and y <= -64 then
  43. if math.random(24 * 24 * 24) <= 27 then
  44. return true
  45. end
  46. end
  47. end
  48. local function spawn_copper(y)
  49. if y >= 1025 and y <= 31000 then
  50. if math.random(9 * 9 * 9) <= 5 then
  51. return true
  52. end
  53. end
  54. if y >= -63 and y <= -16 then
  55. if math.random(12 * 12 * 12) <= 4 then
  56. return true
  57. end
  58. end
  59. if y >= -31000 and y <= -64 then
  60. if math.random(9 * 9 * 9) <= 5 then
  61. return true
  62. end
  63. end
  64. end
  65. local function spawn_tin(y)
  66. if y >= 1025 and y <= 31000 then
  67. if math.random(10 * 10 * 10) <= 5 then
  68. return true
  69. end
  70. end
  71. if y >= -127 and y <= -32 then
  72. if math.random(13 * 13 * 13) <= 4 then
  73. return true
  74. end
  75. end
  76. if y >= -31000 and y <= -128 then
  77. if math.random(10 * 10 * 10) <= 5 then
  78. return true
  79. end
  80. end
  81. end
  82. local function spawn_gold(y)
  83. if y >= 1025 and y <= 31000 then
  84. if math.random(13 * 13 * 13) <= 5 then
  85. return true
  86. end
  87. end
  88. if y >= -255 and y <= -64 then
  89. if math.random(15 * 15 * 15) <= 3 then
  90. return true
  91. end
  92. end
  93. if y >= -31000 and y <= -256 then
  94. if math.random(13 * 13 * 13) <= 5 then
  95. return true
  96. end
  97. end
  98. end
  99. local function spawn_mese(y)
  100. if y >= 1025 and y <= 31000 then
  101. if math.random(14 * 14 * 14) <= 5 then
  102. return true
  103. end
  104. end
  105. if y >= -255 and y <= -64 then
  106. if math.random(18 * 18 * 18) <= 3 then
  107. return true
  108. end
  109. end
  110. if y >= -31000 and y <= -256 then
  111. if math.random(14 * 14 * 14) <= 5 then
  112. return true
  113. end
  114. end
  115. end
  116. local function spawn_diamond(y)
  117. if y >= 1025 and y <= 31000 then
  118. if math.random(15 * 15 * 15) <= 4 then
  119. return true
  120. end
  121. end
  122. if y >= -255 and y <= -128 then
  123. if math.random(17 * 17 * 17) <= 4 then
  124. return true
  125. end
  126. end
  127. if y >= -3100 and y <= -256 then
  128. if math.random(15 * 15 * 15) <= 4 then
  129. return true
  130. end
  131. end
  132. end
  133. function default.cool_lava(pos, node)
  134. local wet = minetest.find_node_near(pos, 1, "group:water")
  135. if node.name == "default:lava_source" and not wet then
  136. minetest.set_node(pos, {name = "default:obsidian"})
  137. elseif wet or (pos.y < -112 and node.name ~= "default:lava_source") then
  138. if spawn_coal(pos.y) then
  139. minetest.set_node(pos, {name = "default:stone_with_coal"})
  140. elseif spawn_iron(pos.y) then
  141. minetest.set_node(pos, {name = "default:stone_with_iron"})
  142. elseif spawn_copper(pos.y) then
  143. minetest.set_node(pos, {name = "default:stone_with_copper"})
  144. elseif spawn_tin(pos.y) then
  145. minetest.set_node(pos, {name = "default:stone_with_tin"})
  146. elseif spawn_gold(pos.y) then
  147. minetest.set_node(pos, {name = "default:stone_with_gold"})
  148. elseif spawn_mese(pos.y) then
  149. minetest.set_node(pos, {name = "default:stone_with_mese"})
  150. elseif spawn_diamond(pos.y) then
  151. minetest.set_node(pos, {name = "default:stone_with_diamond"})
  152. else
  153. minetest.set_node(pos, {name = "default:stone"})
  154. end
  155. else
  156. minetest.set_node(pos, {name = "default:desert_stone"})
  157. end
  158. minetest.sound_play("default_cool_lava", {pos = pos, max_hear_distance = 16, gain = 0.25})
  159. end
  160. minetest.register_alias("renew:obsidian_shard", "default:obsidian")