Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local north,south,east,west = 0
- function getHeading()
- local x,y,z = gps.locate()
- print("Getting Turtle heading...")
- --move 1 block forward / dig and move forward
- if(turtle.detect() == true) then
- turtle.dig()
- turtle.forward()
- else
- turtle.forward()
- end
- local newX,newY,newZ = gps.locate()
- if newX == x then
- if newZ > z then
- print("Facing South")
- south = 1
- else
- print("Facing North")
- north = 1
- end
- else
- if newX > x then
- print("Facing East")
- east = 1
- else
- print("Facing West")
- west = 1
- end
- end
- faceNorth()
- end
- function faceNorth()
- if north == 1 then
- print("Facing North already..")
- end
- if south == 1 then
- turtle.turnRight()
- turtle.turnRight()
- end
- if east == 1 then
- turtle.turnLeft()
- end
- if west == 1 then
- turtle.turnRight()
- end
- end
- getHeading()
Add Comment
Please, Sign In to add comment