ComputerCraft Forums

ComputerCraft => Ask a Pro => Topic started by: Pitaya4 on Jan 23, 2021, 02:39 AM

Title: How do I prevent turtles from breaking tall grass?
Post by: Pitaya4 on Jan 23, 2021, 02:39 AM
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?

Title: How do I prevent turtles from breaking tall grass?
Post by: Lupus590 on Jan 23, 2021, 03:44 AM
I belive that a turtle will be able to detect (https://tweaked.cc/module/turtle.html#v:detect) or inspect (https://tweaked.cc/module/turtle.html#v: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.
Title: How do I prevent turtles from breaking tall grass?
Post by: Pitaya4 on Jan 23, 2021, 12:24 PM
Quote from: Lupus590 on Jan 23, 2021, 03:44 AMI belive that a turtle will be able to detect (https://tweaked.cc/module/turtle.html#v:detect) or inspect (https://tweaked.cc/module/turtle.html#v: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
Title: How do I prevent turtles from breaking tall grass?
Post by: Lupus590 on Jan 23, 2021, 02:05 PM
you could combine the if and the repeat until into a while loop

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