This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
mrpoopy345's profile picture

Pathfinding

Started by mrpoopy345, 12 January 2014 - 01:19 PM
mrpoopy345 #1
Posted 12 January 2014 - 02:19 PM
Hello! I am trying to make a turtle pathfinding program, but he just gets stuck in an infinite loop. Any help?
Code:

turtle.select(1)
while true do
if turtle.compare() then
break
end
if turtle.detect() then
turtle.turnLeft()
else
turtle.digDown()
turtle.forward()
if turtle.detectDown() then
  turtle.turnRight()
  turtle.turnRight()
  turtle.forward()
end
end
end
In the turtles 1st slot there is glowstone
(The stop sign for the turtle.)
Edited on 12 January 2014 - 01:43 PM
CometWolf #2
Posted 12 January 2014 - 02:49 PM
Stuck in an infinte loop doing what exactly? What is it you want him to do? If you want him to stop whenever there is a glowstone infront of him you'll have to add turtle.compare and break after every turn and move
Edited on 12 January 2014 - 01:50 PM
mrpoopy345 #3
Posted 12 January 2014 - 02:55 PM
I fixed it on my own. Sorry for the poor format