liquids_static.lua 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. -- If the water edge is a straight line flowing has 3 neighbors,
  2. -- everything curved inwards would be more, anything outwards would be less.
  3. local function count_source(pos, source)
  4. local p0 = {x=pos.x-1, y=pos.y, z=pos.z-1}
  5. local p1 = {x=pos.x+1, y=pos.y, z=pos.z+1}
  6. local ps = minetest.find_nodes_in_area(p0, p1, {source})
  7. return #ps
  8. end
  9. minetest.register_abm({
  10. label = "Renew water",
  11. nodenames = {"default:water_flowing"},
  12. neighbors = {"default:water_source"},
  13. interval = 1,
  14. chance = 10,
  15. catch_up = false,
  16. action = function(pos, node)
  17. if node.param2 ~= 0 and node.param2 ~= 7 then return end
  18. if count_source(pos, "default:water_source") >= 4 then
  19. minetest.set_node(pos, {name = "default:water_source"})
  20. end
  21. end
  22. })
  23. minetest.register_abm({
  24. label = "Renew lava",
  25. nodenames = {"default:lava_flowing"},
  26. neighbors = {"default:lava_source"},
  27. interval = 1,
  28. chance = 10,
  29. catch_up = false,
  30. action = function(pos, node)
  31. if node.param2 ~= 0 and node.param2 ~= 7 then return end
  32. if count_source(pos, "default:lava_source") >= 4 then
  33. minetest.set_node(pos, {name = "default:lava_source"})
  34. end
  35. end
  36. })