Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- north = 1
- south = 2
- west = 3
- east = 4
- northDir = {0, 1}
- southDir = {0, -1}
- eastDir = {1, 0}
- westDir = {-1, 0}
- -- start at facing north
- currentDir = north
- function faceEast()
- if(currentDir == north) then
- turtle.turnRight()
- elseif(currentDir == west) then
- turtle.turnRight()
- turtle.turnRight()
- elseif(currentDir == south) then
- turtle.turnLeft()
- end
- currentDir = east;
- end
- function faceNorth()
- if(currentDir == east) then
- turtle.turnLeft()
- elseif(currentDir == south) then
- turtle.turnRight()
- turtle.turnRight()
- elseif(currentDir == west) then
- turtle.turnRight()
- end
- currentDir = north;
- end
- function faceSouth()
- if(currentDir == east) then
- turtle.turnRight()
- elseif(currentDir == north) then
- turtle.turnRight()
- turtle.turnRight()
- elseif(currentDir == west) then
- turtle.turnLeft()
- end
- currentDir = south;
- end
- function faceWest()
- if(currentDir == south) then
- turtle.turnRight()
- elseif(currentDir == east) then
- turtle.turnRight()
- turtle.turnRight()
- elseif(currentDir == north) then
- turtle.turnLeft()
- end
- currentDir = west;
- end
- turtle.refuel()
- faceNorth()
- turtle.forward()
- faceEast()
- turtle.forward()
- faceWest()
- turtle.forward()
- faceSouth()
- turtle.forward()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement