papyrus.lua 671 B

1234567891011121314151617181920212223242526
  1. minetest.register_abm({
  2. nodenames = {"default:papyrus"},
  3. interval = 50,
  4. chance = 20,
  5. action = function(pos, node)
  6. pos.y = pos.y-1
  7. local name = minetest.env:get_node(pos).name
  8. if name == "default:dirt" or name == "default:dirt_with_grass" then
  9. if minetest.env:find_node_near(pos, 3, {"default:water_source", "default:water_flowing"}) == nil then
  10. return
  11. end
  12. pos.y = pos.y+1
  13. local height = 0
  14. while minetest.env:get_node(pos).name == "default:papyrus" do
  15. height = height+1
  16. pos.y = pos.y+1
  17. end
  18. if height < 4 then
  19. if minetest.env:get_node(pos).name == "air" then
  20. minetest.env:set_node(pos, node)
  21. end
  22. end
  23. end
  24. end
  25. })