ABMs.lua 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. minetest.register_abm({
  2. label = 'Floating stones',
  3. nodenames = {'epic:float_stone'},
  4. neighbors = {'air'},
  5. interval = 17,
  6. chance = 3,
  7. action = function(pos, node)
  8. local new_pos = ({x=pos.x, y=pos.y+1, z=pos.z})
  9. local abovenode = minetest.get_node(new_pos).name
  10. if abovenode == 'air' then
  11. local timer = minetest.get_node_timer(pos)
  12. timer:start(1)
  13. end
  14. end,
  15. })
  16. --[[
  17. minetest.register_abm({
  18. label = 'Fire Embers',
  19. nodenames = {'default:lava_source', 'default:lava_flowing', 'fire:permanent_flame', 'fire:basic_flame'},
  20. interval = 13,
  21. chance = 7,
  22. action = function(pos, node)
  23. if minetest.get_node({x=pos.x, y=pos.y+1.0, z=pos.z}).name == 'air' then
  24. particles_embers(pos)
  25. end
  26. end
  27. })
  28. --]]
  29. minetest.register_abm({
  30. label = 'sulfur formation',
  31. nodenames = {'default:stone'},
  32. neighbors = {'default:lava_source', 'default:lava_flowing'},
  33. interval = 20,
  34. chance = 60,
  35. action = function(pos, node)
  36. if pos.y < -100 then
  37. if minetest.find_node_near(pos, 3, {'epic:mineral_sulfur'}) ~= nil then
  38. return
  39. end
  40. minetest.set_node(pos, {name='epic:mineral_sulfur'})
  41. end
  42. end,
  43. })
  44. minetest.register_abm({
  45. label = 'lumberjack step removal',
  46. nodenames = {'lumberjack:step'},
  47. interval = 151,
  48. chance = 21,
  49. action = function(pos)
  50. minetest.remove_node(pos)
  51. end
  52. })
  53. minetest.register_abm({
  54. label = 'Glow sapphire growth',
  55. nodenames = {'caverealms:glow_crystal'},
  56. neighbors = {'caverealms:glow_ore'},
  57. interval = 30,
  58. chance = 17,
  59. action = function(pos, node)
  60. local pos1 = {x=pos.x+1, y=pos.y-1, z=pos.z+1}
  61. local pos0 = {x=pos.x-1, y=pos.y-1, z=pos.z-1}
  62. local can_replace = minetest.find_nodes_in_area(pos0, pos1, 'default:lava_source')
  63. local replace_num = #can_replace
  64. if replace_num ~= 8 then
  65. return
  66. end
  67. local height = 0
  68. while node.name == 'caverealms:glow_crystal' and height < 4 do
  69. height = height + 1
  70. pos.y = pos.y + 1
  71. node = minetest.get_node(pos)
  72. end
  73. if height == 4 or node.name ~= 'air' then
  74. return
  75. end
  76. minetest.set_node(pos, {name = 'caverealms:glow_crystal'})
  77. return true
  78. end
  79. })
  80. minetest.register_abm({
  81. label = 'Glow amethyst growth',
  82. nodenames = {'caverealms:glow_amethyst'},
  83. neighbors = {'caverealms:glow_amethyst_ore'},
  84. interval = 30,
  85. chance = 17,
  86. action = function(pos, node)
  87. local pos1 = {x=pos.x+1, y=pos.y-1, z=pos.z+1}
  88. local pos0 = {x=pos.x-1, y=pos.y-1, z=pos.z-1}
  89. local can_replace = minetest.find_nodes_in_area(pos0, pos1, 'default:lava_source')
  90. local replace_num = #can_replace
  91. if replace_num ~= 8 then
  92. return
  93. end
  94. local height = 0
  95. while node.name == 'caverealms:glow_amethyst' and height < 4 do
  96. height = height + 1
  97. pos.y = pos.y + 1
  98. node = minetest.get_node(pos)
  99. end
  100. if height == 4 or node.name ~= 'air' then
  101. return
  102. end
  103. minetest.set_node(pos, {name = 'caverealms:glow_amethyst'})
  104. return true
  105. end
  106. })
  107. minetest.register_abm({
  108. label = 'Glow sapphire growth',
  109. nodenames = {'caverealms:glow_emerald'},
  110. neighbors = {'caverealms:glow_emerald_ore'},
  111. interval = 30,
  112. chance = 17,
  113. action = function(pos, node)
  114. local pos1 = {x=pos.x+1, y=pos.y-1, z=pos.z+1}
  115. local pos0 = {x=pos.x-1, y=pos.y-1, z=pos.z-1}
  116. local can_replace = minetest.find_nodes_in_area(pos0, pos1, 'default:lava_source')
  117. local replace_num = #can_replace
  118. if replace_num ~= 8 then
  119. return
  120. end
  121. local height = 0
  122. while node.name == 'caverealms:glow_emerald' and height < 4 do
  123. height = height + 1
  124. pos.y = pos.y + 1
  125. node = minetest.get_node(pos)
  126. end
  127. if height == 4 or node.name ~= 'air' then
  128. return
  129. end
  130. minetest.set_node(pos, {name = 'caverealms:glow_emerald'})
  131. return true
  132. end
  133. })
  134. minetest.register_abm({
  135. label = 'Glow ruby growth',
  136. nodenames = {'caverealms:glow_ruby'},
  137. neighbors = {'caverealms:glow_ruby_ore'},
  138. interval = 30,
  139. chance = 17,
  140. action = function(pos, node)
  141. local pos1 = {x=pos.x+1, y=pos.y-1, z=pos.z+1}
  142. local pos0 = {x=pos.x-1, y=pos.y-1, z=pos.z-1}
  143. local can_replace = minetest.find_nodes_in_area(pos0, pos1, 'default:lava_source')
  144. local replace_num = #can_replace
  145. if replace_num ~= 8 then
  146. return
  147. end
  148. local height = 0
  149. while node.name == 'caverealms:glow_ruby' and height < 4 do
  150. height = height + 1
  151. pos.y = pos.y + 1
  152. node = minetest.get_node(pos)
  153. end
  154. if height == 4 or node.name ~= 'air' then
  155. return
  156. end
  157. minetest.set_node(pos, {name = 'caverealms:glow_ruby'})
  158. return true
  159. end
  160. })
  161. minetest.register_abm({
  162. label = 'scorched dirt regeneration',
  163. nodenames = {'epic:scorched_dirt'},
  164. neighbors = {
  165. 'group:grass',
  166. 'default:snow',
  167. 'group:soil',
  168. },
  169. interval = 151,
  170. chance = 63,
  171. action = function(pos)
  172. minetest.set_node(pos, {name = 'default:dirt'})
  173. end
  174. })
  175. minetest.register_abm({
  176. label = 'drop burnt trees',
  177. nodenames = {'epic:tree_ash'},
  178. neighbors = {'air'},
  179. interval = 21,
  180. chance = 7,
  181. min_y = 0,
  182. max_y = 1024,
  183. action = function(pos, node)
  184. if node.param2 <= 3 then
  185. local new_pos = ({x=pos.x, y=pos.y-1, z=pos.z})
  186. local below_node = minetest.get_node(new_pos).name
  187. if below_node == 'air' then
  188. minetest.spawn_falling_node(pos)
  189. end
  190. end
  191. end
  192. })