hotsprings.lua 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  1. --[[
  2. minetest.register_node("caverealms:hotspring_seed", {
  3. description = "Hotspring seed",
  4. drawtype = "node",
  5. tiles = {"default_mese_block.png"},
  6. groups = {cracky=3,},
  7. })
  8. ]]
  9. minetest.register_node("caverealms:sulphur_deposit_1", {
  10. description = "Sulphur",
  11. paramtype = "light",
  12. paramtype2 = "facedir",
  13. drawtype = "nodebox",
  14. tiles = {"default_silver_sandstone.png^[colorize:yellow:140"},
  15. -- drops = {},
  16. node_box = {
  17. type = "fixed",
  18. fixed = {
  19. {-.3, -.5, -.3, -0.1, -.45, -0.1},
  20. {.3, -.5, .3, 0.1, -.45, 0.1,},
  21. {-.3, -.5, .3, -0.1, -.45, 0.1},
  22. },
  23. },
  24. groups = {cracky=3, geode_wall = 1 },
  25. })
  26. minetest.register_node("caverealms:fumarole", {
  27. description = "Fumarole",
  28. paramtype = "light",
  29. paramtype2 = "facedir",
  30. drawtype = "nodebox",
  31. tiles = {"default_stone.png^[colorize:black:10"},
  32. drop = 'default:cobble',
  33. damage_per_second = 3,
  34. node_box = {
  35. type = "fixed",
  36. fixed = {
  37. {-.4, -.5, -.4, 0.3, -.4, 0.3},
  38. {-.3+.05, -.4, -.3+.05, 0.2+.05, -.3, 0.2+.05},
  39. {-.2+.08, -.3, -.2+.08, 0.1+.08, -.2, 0.1+.08},
  40. },
  41. },
  42. groups = {cracky=3, },
  43. })
  44. minetest.register_abm({
  45. nodenames = "caverealms:fumarole",
  46. chance = 1,
  47. interval = 20,
  48. action = function(pos, node)
  49. pos.y = pos.y + 0
  50. minetest.add_particlespawner({
  51. amount = 20,
  52. time = 20,
  53. minpos = pos,
  54. maxpos = pos,
  55. minvel = {x=-0.1, y=.6, z=-0.1},
  56. maxvel = {x=0.1, y=1.6, z=0.1},
  57. minacc = {x=-0.1, y=.1, z=-0.1},
  58. maxacc = {x=0.1, y=.1, z=0.1},
  59. minexptime = 2.5,
  60. maxexptime = 4.5,
  61. minsize = 4.2,
  62. maxsize = 5.2,
  63. texture = "tnt_smoke.png",
  64. })
  65. end
  66. })
  67. minetest.register_node("caverealms:hotspring_water_source", {
  68. description = "Hotspring Water Source",
  69. drawtype = "liquid",
  70. light_source = 7,
  71. tiles = {
  72. {
  73. name = "default_river_water_source_animated.png^[colorize:yellow:50",
  74. backface_culling = false,
  75. animation = {
  76. type = "vertical_frames",
  77. aspect_w = 16,
  78. aspect_h = 16,
  79. length = 2.0,
  80. },
  81. },
  82. {
  83. name = "default_river_water_source_animated.png^[colorize:yellow:50",
  84. backface_culling = true,
  85. animation = {
  86. type = "vertical_frames",
  87. aspect_w = 16,
  88. aspect_h = 16,
  89. length = 2.0,
  90. },
  91. },
  92. },
  93. alpha = 160,
  94. paramtype = "light",
  95. walkable = false,
  96. pointable = false,
  97. diggable = false,
  98. buildable_to = true,
  99. is_ground_content = false,
  100. drop = "",
  101. drowning = 1,
  102. liquidtype = "source",
  103. liquid_alternative_flowing = "caverealms:hotspring_water_flowing",
  104. liquid_alternative_source = "caverealms:hotspring_water_source",
  105. liquid_viscosity = 1,
  106. -- Not renewable to avoid horizontal spread of water sources in sloping
  107. -- rivers that can cause water to overflow riverbanks and cause floods.
  108. -- River water source is instead made renewable by the 'force renew'
  109. -- option used in the 'bucket' mod by the river water bucket.
  110. liquid_renewable = false,
  111. liquid_range = 2,
  112. damage_per_second = 1,
  113. post_effect_color = {a = 103, r = 60, g = 96, b = 90},
  114. groups = {water = 3, liquid = 3, cools_lava = 1},
  115. sounds = default.node_sound_water_defaults(),
  116. })
  117. minetest.register_node("caverealms:hotspring_water_flowing", {
  118. description = "Flowing Hotspring Water",
  119. drawtype = "flowingliquid",
  120. tiles = {"default_river_water.png^[colorize:yellow:50"},
  121. special_tiles = {
  122. {
  123. name = "default_river_water_flowing_animated.png^[colorize:yellow:50",
  124. backface_culling = false,
  125. animation = {
  126. type = "vertical_frames",
  127. aspect_w = 16,
  128. aspect_h = 16,
  129. length = 0.8,
  130. },
  131. },
  132. {
  133. name = "default_river_water_flowing_animated.png^[colorize:yellow:50",
  134. backface_culling = true,
  135. animation = {
  136. type = "vertical_frames",
  137. aspect_w = 16,
  138. aspect_h = 16,
  139. length = 0.8,
  140. },
  141. },
  142. },
  143. alpha = 160,
  144. paramtype = "light",
  145. paramtype2 = "flowingliquid",
  146. walkable = false,
  147. pointable = false,
  148. diggable = false,
  149. buildable_to = true,
  150. is_ground_content = false,
  151. drop = "",
  152. drowning = 1,
  153. liquidtype = "flowing",
  154. liquid_alternative_flowing = "caverealms:hotspring_water_flowing",
  155. liquid_alternative_source = "caverealms:hotspring_water_source",
  156. liquid_viscosity = 1,
  157. liquid_renewable = false,
  158. liquid_range = 2,
  159. damage_per_second = 1,
  160. post_effect_color = {a = 103, r = 60, g = 96, b = 90},
  161. groups = {water = 3, liquid = 3, not_in_creative_inventory = 1,
  162. cools_lava = 1},
  163. sounds = default.node_sound_water_defaults(),
  164. })
  165. minetest.register_node("caverealms:scalding_stone_1", {
  166. description = "Scalding Stone",
  167. tiles = {"default_stone.png^[colorize:orange:120"},
  168. groups = {cracky = 3, scalding_stone = 1},
  169. drop = 'default:cobble',
  170. damage_per_second = 1,
  171. sounds = default.node_sound_stone_defaults(),
  172. })
  173. minetest.register_node("caverealms:scalding_stone_2", {
  174. description = "Scalding Stone",
  175. tiles = {"default_stone.png^[colorize:yellow:80"},
  176. groups = {cracky = 3, scalding_stone = 1},
  177. drop = 'default:cobble',
  178. damage_per_second = 1,
  179. sounds = default.node_sound_stone_defaults(),
  180. })
  181. minetest.register_node("caverealms:scalding_stone_3", {
  182. description = "Scalding Stone",
  183. tiles = {"default_desert_stone.png^[colorize:orange:120"},
  184. groups = {cracky = 3, scalding_stone = 1},
  185. drop = 'default:cobble',
  186. damage_per_second = 1,
  187. sounds = default.node_sound_stone_defaults(),
  188. })
  189. minetest.register_node("caverealms:scalding_stone_4", {
  190. description = "Scalding Stone",
  191. tiles = {"default_desert_stone.png^[colorize:yellow:80"},
  192. groups = {cracky = 3, scalding_stone = 1},
  193. drop = 'default:cobble',
  194. damage_per_second = 1,
  195. sounds = default.node_sound_stone_defaults(),
  196. })
  197. minetest.register_node("caverealms:scalding_stone_5", {
  198. description = "Scalding Stone",
  199. tiles = {"default_stone.png^[colorize:red:80"},
  200. groups = {cracky = 3, scalding_stone = 1},
  201. drop = 'default:cobble',
  202. damage_per_second = 1,
  203. sounds = default.node_sound_stone_defaults(),
  204. })
  205. local scalding_stones = {
  206. minetest.get_content_id("caverealms:scalding_stone_1"),
  207. minetest.get_content_id("caverealms:scalding_stone_2"),
  208. minetest.get_content_id("caverealms:scalding_stone_3"),
  209. minetest.get_content_id("caverealms:scalding_stone_4"),
  210. minetest.get_content_id("caverealms:scalding_stone_5"),
  211. }
  212. local scalding_stone_names = {
  213. "caverealms:scalding_stone_1",
  214. "caverealms:scalding_stone_2",
  215. "caverealms:scalding_stone_3",
  216. "caverealms:scalding_stone_4",
  217. "caverealms:scalding_stone_5",
  218. }
  219. local function dist3(a, b)
  220. local x = a.x - b.x
  221. local y = a.y - b.y
  222. local z = a.z - b.z
  223. return math.sqrt(x*x + y*y + z*z)
  224. end
  225. -- local function spawn_hotspring(pos, size)
  226. function caverealms:spawn_hotspring(px,py,pz, area, data, size)
  227. local c_hotspring = minetest.get_content_id("caverealms:hotspring_water_source")
  228. local r = size
  229. local r2 = math.ceil(r+1)
  230. for x = px-r2,px+r2,1 do
  231. for y = -r2,r2,1 do
  232. for z = pz-r2,pz+r2,1 do
  233. local p = {x=x, y=py+y, z=z}
  234. local p_squash = {x=x, y=py + (y*2), z=z}
  235. local d = dist3(p_squash, {x=px, y=py, z=pz})
  236. d = d + math.random() * .5
  237. local dd = d - r
  238. local n = minetest.get_node(p)
  239. if n.name ~= "air" then
  240. if dd <= -.5 then
  241. local vi = area:index(x, py+y, z)
  242. data[vi] = c_hotspring
  243. elseif dd < 1.5 then
  244. local vi = area:index(x, py+y, z)
  245. data[vi] = scalding_stones[math.random(#scalding_stones)]
  246. end
  247. end
  248. end
  249. end
  250. end
  251. end
  252. minetest.register_abm({
  253. nodenames = "caverealms:hotspring_water_source",
  254. chance = 60,
  255. interval = 5,
  256. action = function(pos, node)
  257. minetest.add_particlespawner({
  258. amount = 1,
  259. time = 1,
  260. minpos = pos,
  261. maxpos = pos,
  262. minvel = {x=-0.1, y=.6, z=-0.1},
  263. maxvel = {x=0.1, y=1.6, z=0.1},
  264. minacc = {x=-0.1, y=.1, z=-0.1},
  265. maxacc = {x=0.1, y=.1, z=0.1},
  266. minexptime = 3.5,
  267. maxexptime = 6.5,
  268. minsize = 10.2,
  269. maxsize = 12.2,
  270. texture = "tnt_smoke.png",
  271. })
  272. end
  273. })
  274. local function random_pos(pos, dist)
  275. local p = {
  276. x=pos.x + math.random(-dist, dist),
  277. y=pos.y + dist,
  278. z=pos.z + math.random(-dist, dist),
  279. }
  280. while p.y > pos.y - dist do
  281. local n = minetest.get_node(p)
  282. if n.name ~= "air" and n.name ~= "ignore" then
  283. if n.name == "default:water_source" or n.name == "default:water_flowing" then
  284. return nil
  285. end
  286. return p
  287. end
  288. p.y = p.y - 1
  289. end
  290. return nil
  291. end
  292. -- life dies near hotsprings
  293. minetest.register_abm({
  294. nodenames = "group:flora",
  295. neighbors = {"group:scalding_stone"},
  296. chance = 10,
  297. interval = 15,
  298. action = function(pos, node)
  299. minetest.set_node(pos, {name="air"})
  300. end
  301. })
  302. -- life dies near hotsprings
  303. minetest.register_abm({
  304. nodenames = "group:flora",
  305. neighbors = {"group:scalding_stone"},
  306. chance = 80,
  307. interval = 15,
  308. action = function(pos, node)
  309. local p = minetest.find_node_near(pos, 15, {"group:flora", "group:sapling", "group:leaves", "group:leafdecay"})
  310. if p then
  311. minetest.set_node(p, {name="air"})
  312. end
  313. end
  314. })
  315. -- minerals accumulate
  316. minetest.register_abm({
  317. nodenames = "group:scalding_stone",
  318. neighbors = {"air"},
  319. chance = 180,
  320. interval = 30,
  321. action = function(pos, node)
  322. -- TODO: place sulphur on sides too
  323. pos.y = pos.y + 1
  324. local n = minetest.get_node(pos)
  325. if n.name == "air" then
  326. minetest.set_node(pos, {name="caverealms:sulphur_deposit_1"})
  327. end
  328. end
  329. })
  330. -- water scalds stone
  331. minetest.register_abm({
  332. nodenames = {"group:stone", "group:dirt"},
  333. neighbors = {"caverealms:hotspring_water_source", "caverealms:hotspring_water_flowing"},
  334. chance = 80,
  335. interval = 10,
  336. action = function(pos, node)
  337. minetest.set_node(pos, {name=scalding_stone_names[math.random(#scalding_stone_names)]})
  338. end
  339. })
  340. -- stones scald dirt
  341. minetest.register_abm({
  342. nodenames = "group:soil",
  343. neighbors = {"group:scalding_stone"},
  344. chance = 80,
  345. interval = 10,
  346. action = function(pos, node)
  347. minetest.set_node(pos, {name="default:stone"})
  348. end
  349. })
  350. -- water melts snow
  351. minetest.register_abm({
  352. nodenames = {"default:snow", "default:snowblock"},
  353. neighbors = {"caverealms:hotspring_water_source", "caverealms:hotspring_water_flowing"},
  354. chance = 80,
  355. interval = 10,
  356. action = function(pos, node)
  357. minetest.set_node(pos, {name="air"})
  358. end
  359. })
  360. --[[ add hotspring seeds to mapgen
  361. minetest.register_decoration({
  362. name = "caverealms:hotspring_seed",
  363. deco_type = "simple",
  364. place_on = {"default:dirt_with_grass", "default:dirt_with_snow", "default:snowblock",
  365. "default:silver_sand", "default:sand", "default:desert_sand"
  366. },
  367. place_offset_y = 1,
  368. sidelen = 16,
  369. noise_params = {
  370. offset = -0.010,
  371. scale = 0.01,
  372. spread = {x = 200, y = 200, z = 200},
  373. seed = 65645647,
  374. octaves = 3,
  375. persist = 0.7,
  376. },
  377. biomes = {"grassland", "snowy_grassland", "tundra", "taiga", "desert", "cold_desert", "sandstone_desert"},
  378. y_max = 1000,
  379. y_min = 5,
  380. place_offset_y = 1,
  381. decoration = "caverealms:hotspring_seed",
  382. flags = "force_placement",
  383. })
  384. ]]
  385. -- hotsprings boil rivers
  386. minetest.register_abm({
  387. nodenames = {"default:river_water_source"},
  388. neighbors = {"caverealms:hotspring_water_source", "caverealms:hotspring_water_flowing"},
  389. chance = 15,
  390. interval = 5,
  391. action = function(pos, node)
  392. -- only spread downhill
  393. local hw = minetest.find_nodes_in_area(
  394. {x=pos.x-1, y=pos.y, z=pos.z-1},
  395. {x=pos.x+1, y=pos.y+1, z=pos.z+1},
  396. {"caverealms:hotspring_water_source", "caverealms:hotspring_water_flowing"})
  397. if not hw or #hw == 0 then
  398. return
  399. end
  400. -- don't spread under rivers
  401. pos.y = pos.y + 1
  402. local n = minetest.get_node(pos)
  403. if n.name == "default:river_water_source" or n.name == "default:river_water_flowing" then
  404. return
  405. end
  406. pos.y = pos.y - 1
  407. minetest.set_node(pos, {name="caverealms:hotspring_water_source"})
  408. end
  409. })