Advertisement
lemmy101

Untitled

Apr 24th, 2015
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. north = 1
  2. south = 2
  3. west = 3
  4. east = 4
  5.  
  6. northDir = {0, 1}
  7. southDir = {0, -1}
  8. eastDir = {1, 0}
  9. westDir = {-1, 0}
  10.  
  11. -- start at facing north
  12. currentDir = north
  13.  
  14. function faceEast()
  15. if(currentDir == north) then
  16. turtle.turnRight()
  17. elseif(currentDir == west) then
  18. turtle.turnRight()
  19. turtle.turnRight()
  20. elseif(currentDir == south) then
  21. turtle.turnLeft()
  22. end
  23. currentDir = east;
  24. end
  25.  
  26. function faceNorth()
  27. if(currentDir == east) then
  28. turtle.turnLeft()
  29. elseif(currentDir == south) then
  30. turtle.turnRight()
  31. turtle.turnRight()
  32. elseif(currentDir == west) then
  33. turtle.turnRight()
  34. end
  35. currentDir = north;
  36. end
  37.  
  38. function faceSouth()
  39. if(currentDir == east) then
  40. turtle.turnRight()
  41. elseif(currentDir == north) then
  42. turtle.turnRight()
  43. turtle.turnRight()
  44. elseif(currentDir == west) then
  45. turtle.turnLeft()
  46. end
  47. currentDir = south;
  48. end
  49.  
  50. function faceWest()
  51. if(currentDir == south) then
  52. turtle.turnRight()
  53. elseif(currentDir == east) then
  54. turtle.turnRight()
  55. turtle.turnRight()
  56. elseif(currentDir == north) then
  57. turtle.turnLeft()
  58. end
  59. currentDir = west;
  60. end
  61.  
  62. turtle.refuel()
  63.  
  64. faceNorth()
  65. turtle.forward()
  66. faceEast()
  67. turtle.forward()
  68. faceWest()
  69. turtle.forward()
  70. faceSouth()
  71. turtle.forward()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement