Jump to content




Pathfinding


  • You cannot reply to this topic
2 replies to this topic

#1 mrpoopy345

  • Members
  • 148 posts
  • LocationMy Computer

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 by mrpoopy345, 12 January 2014 - 02:43 PM.


#2 CometWolf

  • Members
  • 1,283 posts

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 by CometWolf, 12 January 2014 - 02:50 PM.


#3 mrpoopy345

  • Members
  • 148 posts
  • LocationMy Computer

Posted 12 January 2014 - 02:55 PM

I fixed it on my own. Sorry for the poor format





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users