coffedahl

gps

Nov 30th, 2020 (edited)
962
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --Get the startingposition for the turtle
  2. local home = vector.new(-93,69,249)
  3. --Move away from the original position
  4.  
  5. --Turn to positive x direction
  6.     --Get direction
  7. local position = vector.new(gps.locate(5))
  8. turtle.forward()
  9. local new_position = vector.new(gps.locate(5))
  10. local diff = new_position - position
  11.     --Move to positive x
  12. if (diff.x < 0) then
  13.     turtle.turnRight()
  14.     turtle.turnRight()
  15. elseif (diff.z > 0) then
  16.     turtle.turnLeft()
  17. elseif (diff.z < 0) then
  18.     turtle.turnRight()
  19. end
  20.  
  21. -- Move to the correct x posistion
  22. diff = new_position - home
  23. print(diff.x)
RAW Paste Data