How do I prevent turtles from breaking tall grass?

Started by Pitaya4, Jan 23, 2021, 02:39 AM

Previous topic - Next topic

Pitaya4

I'm making a system similar to Google Maps. I have got it working perfectly, however, turtles break tall grass when they move. Is there a way to not do that? They already avoid opaque blocks, is there an option to include transparent blocks too?


Lupus590

I belive that a turtle will be able to detect or inspect the grass, you could try using either of those functions before every movement, it will slow the movement down as the detect and, especially, inspect take a little bit of time to return.

Pitaya4

Quote from: Lupus590 on Jan 23, 2021, 03:44 AMI belive that a turtle will be able to detect or inspect the grass, you could try using either of those functions before every movement, it will slow the movement down as the detect and, especially, inspect take a little bit of time to return.

Thanks! That did the trick. I just changed the statement for going down from:
repeat
  turtle.down()
until turtle.detectDown()
to
if not turtle.detectDown() then
  repeat
      turtle.down()
  until turtle.detectDown()
end

Lupus590

you could combine the if and the repeat until into a while loop

while not turtle.detectDown() do
    turtle.down()
end