vapors.lua 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. -- more concentrated
  2. minetest.register_node("bitumen:vapor_2", {
  3. description = "Vapor",
  4. drawtype = "airlike",
  5. pointable = false,
  6. diggable = false,
  7. walkable = false,
  8. buildable_to = true,
  9. paramtype = "light",
  10. sunlight_propagates = true,
  11. -- post_effect_color = info.post_effect_color,
  12. -- tiles = { "default_copper_block.png" },
  13. groups = { not_in_creative_inventory = 1, bitumen_vapor = 1 },
  14. })
  15. -- less concentrated
  16. minetest.register_node("bitumen:vapor_1", {
  17. description = "Vapor",
  18. drawtype = "airlike",
  19. pointable = false,
  20. diggable = false,
  21. walkable = false,
  22. buildable_to = true,
  23. paramtype = "light",
  24. sunlight_propagates = true,
  25. -- tiles = { "default_steel_block.png" },
  26. groups = { not_in_creative_inventory = 1, bitumen_vapor = 1 },
  27. })
  28. --[[ for testing
  29. minetest.register_node("bitumen:vapor_gen", {
  30. description = "Vapor Generator",
  31. tiles = { "default_steel_block.png" },
  32. groups = { cracky = 1 },
  33. })
  34. minetest.register_abm({
  35. nodenames = {"bitumen:vapor_gen"},
  36. neighbors = {"air"},
  37. interval = 3,
  38. chance = 1,
  39. action = function(pos, node, active_object_count, active_object_count_wider)
  40. pos.y = pos.y + 1
  41. minetest.set_node(pos, {name="bitumen:vapor_2"})
  42. end
  43. })
  44. ]]
  45. -- move around randomly
  46. minetest.register_abm({
  47. nodenames = {"bitumen:vapor_2", "bitumen:vapor_1"},
  48. neighbors = {"air"},
  49. interval = 4,
  50. chance = 8,
  51. action = function(pos, node, active_object_count, active_object_count_wider)
  52. local name = node.name
  53. local air_nodes = minetest.find_nodes_in_area(
  54. {x=pos.x - 1, y=pos.y - 1, z=pos.z - 1},
  55. {x=pos.x + 1, y=pos.y, z=pos.z + 1},
  56. "air"
  57. )
  58. -- try to go down first
  59. if #air_nodes > 0 and math.random(6) > 1 then
  60. local off = math.random(#air_nodes)
  61. --print("off "..dump(off).. " - " .. dump(#air_nodes))
  62. minetest.set_node(pos, {name="air"})
  63. minetest.set_node(air_nodes[off], {name=name})
  64. return
  65. end
  66. -- go up if there's no down
  67. air_nodes = minetest.find_nodes_in_area(
  68. {x=pos.x - 1, y=pos.y + 1, z=pos.z - 1},
  69. {x=pos.x + 1, y=pos.y + 1, z=pos.z + 1},
  70. "air"
  71. )
  72. if #air_nodes > 0 then
  73. local off = math.random(#air_nodes)
  74. minetest.set_node(pos, {name="air"})
  75. minetest.set_node(air_nodes[off], {name=name})
  76. end
  77. end
  78. })
  79. -- diffuse away completely
  80. minetest.register_abm({
  81. nodenames = {"bitumen:vapor_1"},
  82. neighbors = {"air"},
  83. interval = 8,
  84. chance = 16,
  85. action = function(pos, node)
  86. local air_nodes = minetest.find_nodes_in_area(
  87. {x=pos.x - 1, y=pos.y - 1, z=pos.z - 1},
  88. {x=pos.x + 1, y=pos.y + 1, z=pos.z + 1},
  89. "air"
  90. )
  91. if #air_nodes > 12 then
  92. minetest.set_node(pos, {name="air"})
  93. end
  94. end
  95. })
  96. -- diffuse
  97. minetest.register_abm({
  98. nodenames = {"bitumen:vapor_2"},
  99. neighbors = {"air"},
  100. interval = 4,
  101. chance = 4,
  102. action = function(pos, node, active_object_count, active_object_count_wider)
  103. local air_nodes = minetest.find_nodes_in_area(
  104. {x=pos.x - 1, y=pos.y - 1, z=pos.z - 1},
  105. {x=pos.x + 1, y=pos.y + 1, z=pos.z + 1},
  106. "air"
  107. )
  108. if #air_nodes > 0 then
  109. local off = math.random(#air_nodes)
  110. --print("off "..dump(off).. " - " .. dump(#air_nodes))
  111. minetest.set_node(pos, {name="bitumen:vapor_1"})
  112. minetest.set_node(air_nodes[off], {name="bitumen:vapor_1"})
  113. end
  114. end
  115. })
  116. -- go up in flames
  117. minetest.register_abm({
  118. nodenames = {"bitumen:vapor_1", "bitumen:vapor_2"},
  119. neighbors = {"group:igniter", "default:torch", "default:furnace_active"},
  120. interval = 1,
  121. chance = 3,
  122. action = function(pos, node, active_object_count, active_object_count_wider)
  123. local air_nodes = minetest.find_nodes_in_area(
  124. {x=pos.x - 1, y=pos.y - 1, z=pos.z - 1},
  125. {x=pos.x + 1, y=pos.y + 1, z=pos.z + 1},
  126. {"air", "group:flammable"}
  127. )
  128. if #air_nodes > 0 then
  129. local off = math.random(#air_nodes)
  130. local num = math.random(#air_nodes / 2)
  131. for i = 1,num do
  132. --local theirlevel = minetest.get_node_level(fp)
  133. local fp = air_nodes[((i + off) % #air_nodes) + 1]
  134. minetest.set_node(fp, {name="fire:basic_flame"})
  135. end
  136. end
  137. minetest.set_node(pos, {name="fire:basic_flame"})
  138. end
  139. })