cactus.lua 542 B

1234567891011121314151617181920212223
  1. minetest.register_abm({
  2. nodenames = {"default:cactus"},
  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:desert_sand" or name == "default:sand" then
  9. pos.y = pos.y+1
  10. local height = 0
  11. while minetest.env:get_node(pos).name == "default:cactus" do
  12. height = height+1
  13. pos.y = pos.y+1
  14. end
  15. if height < 4 then
  16. if minetest.env:get_node(pos).name == "air" then
  17. minetest.env:set_node(pos, node)
  18. end
  19. end
  20. end
  21. end
  22. })