ABMs.lua 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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. minetest.register_abm({
  17. label = 'Fire Embers',
  18. nodenames = {'default:lava_source', 'default:lava_flowing', 'fire:permanent_flame', 'fire:basic_flame'},
  19. interval = 13,
  20. chance = 7,
  21. action = function(pos, node)
  22. if minetest.get_node({x=pos.x, y=pos.y+1.0, z=pos.z}).name == 'air' then
  23. particles_embers(pos)
  24. end
  25. end
  26. })
  27. minetest.register_abm({
  28. label = 'sulfur formation',
  29. nodenames = {'default:stone'},
  30. neighbors = {'default:lava_source', 'default:lava_flowing'},
  31. interval = 20,
  32. chance = 60,
  33. action = function(pos, node)
  34. if pos.y < -100 then
  35. if minetest.find_node_near(pos, 3, {'epic:mineral_sulfur'}) ~= nil then
  36. return
  37. end
  38. minetest.set_node(pos, {name='epic:mineral_sulfur'})
  39. end
  40. end,
  41. })
  42. minetest.register_abm({
  43. label = 'lumberjack step removal',
  44. nodenames = {'lumberjack:step'},
  45. interval = 151,
  46. chance = 21,
  47. action = function(pos)
  48. minetest.remove_node(pos)
  49. end
  50. })
  51. minetest.register_abm({
  52. label = 'Glow sapphire growth',
  53. nodenames = {'caverealms:glow_crystal'},
  54. neighbors = {'caverealms:glow_ore'},
  55. interval = 30,
  56. chance = 17,
  57. action = function(pos, node)
  58. local pos1 = {x=pos.x+1, y=pos.y-1, z=pos.z+1}
  59. local pos0 = {x=pos.x-1, y=pos.y-1, z=pos.z-1}
  60. local can_replace = minetest.find_nodes_in_area(pos0, pos1, 'default:lava_source')
  61. local replace_num = #can_replace
  62. if replace_num ~= 8 then
  63. return
  64. end
  65. local height = 0
  66. while node.name == "caverealms:glow_crystal" and height < 4 do
  67. height = height + 1
  68. pos.y = pos.y + 1
  69. node = minetest.get_node(pos)
  70. end
  71. if height == 4 or node.name ~= 'air' then
  72. return
  73. end
  74. minetest.set_node(pos, {name = 'caverealms:glow_crystal'})
  75. return true
  76. end
  77. })
  78. minetest.register_abm({
  79. label = 'Glow amethyst growth',
  80. nodenames = {'caverealms:glow_amethyst'},
  81. neighbors = {'caverealms:glow_amethyst_ore'},
  82. interval = 30,
  83. chance = 17,
  84. action = function(pos, node)
  85. local pos1 = {x=pos.x+1, y=pos.y-1, z=pos.z+1}
  86. local pos0 = {x=pos.x-1, y=pos.y-1, z=pos.z-1}
  87. local can_replace = minetest.find_nodes_in_area(pos0, pos1, 'default:lava_source')
  88. local replace_num = #can_replace
  89. if replace_num ~= 8 then
  90. return
  91. end
  92. local height = 0
  93. while node.name == "caverealms:glow_amethyst" and height < 4 do
  94. height = height + 1
  95. pos.y = pos.y + 1
  96. node = minetest.get_node(pos)
  97. end
  98. if height == 4 or node.name ~= 'air' then
  99. return
  100. end
  101. minetest.set_node(pos, {name = 'caverealms:glow_amethyst'})
  102. return true
  103. end
  104. })
  105. minetest.register_abm({
  106. label = 'Glow sapphire growth',
  107. nodenames = {'caverealms:glow_emerald'},
  108. neighbors = {'caverealms:glow_emerald_ore'},
  109. interval = 30,
  110. chance = 17,
  111. action = function(pos, node)
  112. local pos1 = {x=pos.x+1, y=pos.y-1, z=pos.z+1}
  113. local pos0 = {x=pos.x-1, y=pos.y-1, z=pos.z-1}
  114. local can_replace = minetest.find_nodes_in_area(pos0, pos1, 'default:lava_source')
  115. local replace_num = #can_replace
  116. if replace_num ~= 8 then
  117. return
  118. end
  119. local height = 0
  120. while node.name == "caverealms:glow_emerald" and height < 4 do
  121. height = height + 1
  122. pos.y = pos.y + 1
  123. node = minetest.get_node(pos)
  124. end
  125. if height == 4 or node.name ~= 'air' then
  126. return
  127. end
  128. minetest.set_node(pos, {name = 'caverealms:glow_emerald'})
  129. return true
  130. end
  131. })
  132. minetest.register_abm({
  133. label = 'Glow ruby growth',
  134. nodenames = {'caverealms:glow_ruby'},
  135. neighbors = {'caverealms:glow_ruby_ore'},
  136. interval = 30,
  137. chance = 17,
  138. action = function(pos, node)
  139. local pos1 = {x=pos.x+1, y=pos.y-1, z=pos.z+1}
  140. local pos0 = {x=pos.x-1, y=pos.y-1, z=pos.z-1}
  141. local can_replace = minetest.find_nodes_in_area(pos0, pos1, 'default:lava_source')
  142. local replace_num = #can_replace
  143. if replace_num ~= 8 then
  144. return
  145. end
  146. local height = 0
  147. while node.name == 'caverealms:glow_ruby' and height < 4 do
  148. height = height + 1
  149. pos.y = pos.y + 1
  150. node = minetest.get_node(pos)
  151. end
  152. if height == 4 or node.name ~= 'air' then
  153. return
  154. end
  155. minetest.set_node(pos, {name = 'caverealms:glow_ruby'})
  156. return true
  157. end
  158. })