Guest User

Untitled

a guest
May 18th, 2013
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1.  
  2.  
  3. m = peripheral.wrap("front")
  4. c = peripheral.wrap("right")
  5. facing = c.getFacing()
  6. x = 0
  7. y = 0
  8. canMove = false
  9.  
  10. function canMove()
  11. if turtle.detect() then
  12. return false
  13. else
  14. return true
  15. end
  16. end
  17. function move()
  18. if canMove() then
  19. turtle.forward()
  20. if facing == 0 then
  21. y = y -1
  22. end
  23. if facing == 1 then
  24. x = x +1
  25. end
  26. if facing == 2 then
  27. y = y +1
  28. end
  29. if facing == 3 then
  30. x = x -1
  31. end
  32. end
  33. print("x = "..x.." y = "..y.."")
  34. end
  35. --the turning fuction
  36. function face(f)
  37. facing = c.getFacing()
  38. while facing ~= f do
  39. turtle.turnLeft()
  40. facing = c.getFacing()
  41. end
  42. end
  43. -- move to function
  44. function goto(goX,goY)
  45. --turn at portal
  46.  
  47. if x ==0 and y == 0 and facing~= 2 then
  48. face(2)
  49. end
  50.  
  51. --get out of middle
  52. function leaveMiddle()
  53. if goY ~= y or goX ~= x then
  54. if x ~=0 or x ~= 6 and y ~= 15 then
  55. if goX == 6 then
  56. face(3)
  57. else
  58. face(1)
  59. end
  60. end
  61. while x ~= goX do
  62. move()
  63. end
  64. end
  65. end
  66. -- goto right side
  67. if goY ~= y or goX ~= x then
  68. if goX == 6 and x ~= 6 then
  69. if y ~= 3 or y ~= 15 then
  70. if y > 9 then
  71. face(2)
  72. while y ~= 15 do
  73. move()
  74. end
  75. end
  76. if y < 9 and y > 3 then
  77. face(0)
  78. while y ~= 3 do
  79. move()
  80. end
  81. end
  82. if y < 3 then
  83. face(3)
  84. while y < 3 do
  85. move()
  86. end
  87. end
  88. end
  89. end
  90. end
  91. if goY > y and goY ~= y then
  92. face(2)
  93. else
  94. if goY < y and goY ~= y then
  95. face(0)
  96. end
  97. while y ~= goY do
  98. move()
  99. end
  100. end
  101.  
  102. function getBookOne()
  103. goto(1,1)
  104. end
  105. getBookOne()
Advertisement
Add Comment
Please, Sign In to add comment