Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. function farm (xLength, yLength)
  2. for x = 1, xLength, 1 do
  3. for y = 1, yLength, 1 do
  4. nineXNine(9,9)
  5. if y != yLength then
  6. goToNextJobY()
  7. end
  8. end
  9. if x != xLength then
  10. goToNextJobX(yLength)
  11. end
  12. end
  13. goHomeBig(xLength, yLength)
  14. end
  15.  
  16. function goToNextJobX(yLength)
  17. turtle.turnRight()
  18. turtle.turnRight()
  19. goForward(((yLength-1)*10)-1)
  20. turtle.turnRight()
  21. goForward(10)
  22. turtle.turnLeft()
  23. end
  24.  
  25. function goToNextJobY()
  26. goForward(10)
  27. end
  28.  
  29. function goHomeBig(xLength, yLength)
  30.  
  31. end
  32.  
  33. function nineXNine(targetLength, targetWidth)
  34.  
  35. for width = 1, targetWidth, 1 do
  36. processLine(targetLength)
  37.  
  38. if width == targetWidth then
  39. goHome(targetLength, targetWidth)
  40. elseif width%2 == 1 then
  41. turnRight()
  42. nextMoveIsRight = false
  43. else
  44. turnLeft()
  45. nextMoveIsRight = true
  46. end
  47. end
  48. end
  49.  
  50. function processLine(targetLength)
  51. doWork()
  52. for length = 1, targetLength-1, 1 do
  53. turtle.forward()
  54. doWork()
  55. end
  56. end
  57.  
  58. function doWork()
  59. turtle.digDown()
  60. turtle.placeDown()
  61. end
  62.  
  63. function turnRight()
  64. turtle.turnRight()
  65. turtle.forward()
  66. turtle.turnRight()
  67. end
  68.  
  69. function turnLeft()
  70. turtle.turnLeft()
  71. turtle.forward()
  72. turtle.turnLeft()
  73. end
  74.  
  75. function turnAround()
  76. turtle.turnLeft()
  77. turtle.turnLeft()
  78. end
  79.  
  80. function goForward(lengthToGo)
  81. for lengthWent = 1, lengthToGo, 1 do
  82. turtle.forward()
  83. end
  84. end
  85.  
  86. function goHome(targetLength, targetWidth)
  87. if(targetWidth%2 == 1) then
  88. turnAround()
  89. goForward(targetLength-1)
  90. end
  91.  
  92. turtle.turnRight()
  93. goForward(targetWidth-1)
  94. turtle.turnRight()
  95. end
  96.  
  97. nineXNine(9, 9)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement