Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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)
  20. turtle.turnLeft()
  21. goForward(10)
  22. turtle.turnLeft()
  23.  
  24. end
  25.  
  26. function goToNextJobY()
  27. goForward(10)
  28. end
  29.  
  30. function goHomeBig(xLength, yLength)
  31. turtle.turnRight()
  32. turtle.turnRight()
  33. goForward((yLength-1)*10)
  34. turtle.turnRight()
  35. goForward((xLength-1)*10)
  36. turtle.turnRight()
  37. end
  38.  
  39. function nineXNine(targetLength, targetWidth)
  40.  
  41. for width = 1, targetWidth, 1 do
  42. processLine(targetLength)
  43.  
  44. if width == targetWidth then
  45. goHome(targetLength, targetWidth)
  46. elseif width%2 == 1 then
  47. turnRight()
  48. nextMoveIsRight = false
  49. else
  50. turnLeft()
  51. nextMoveIsRight = true
  52. end
  53. end
  54. end
  55.  
  56. function processLine(targetLength)
  57. doWork()
  58. for length = 1, targetLength-1, 1 do
  59. turtle.forward()
  60. doWork()
  61. end
  62. end
  63.  
  64. function doWork()
  65. selectSeeds()
  66. turtle.digDown()
  67. turtle.placeDown()
  68. end
  69.  
  70. function selectSeeds()
  71. end
  72.  
  73. function turnRight()
  74. turtle.turnRight()
  75. turtle.forward()
  76. turtle.turnRight()
  77. end
  78.  
  79. function turnLeft()
  80. turtle.turnLeft()
  81. turtle.forward()
  82. turtle.turnLeft()
  83. end
  84.  
  85. function turnAround()
  86. turtle.turnLeft()
  87. turtle.turnLeft()
  88. end
  89.  
  90. function goForward(lengthToGo)
  91. for lengthWent = 1, lengthToGo, 1 do
  92. turtle.forward()
  93. end
  94. end
  95.  
  96. function goHome(targetLength, targetWidth)
  97. if(targetWidth%2 == 1) then
  98. turnAround()
  99. goForward(targetLength-1)
  100. end
  101.  
  102. turtle.turnRight()
  103. goForward(targetWidth-1)
  104. turtle.turnRight()
  105. end
  106.  
  107. farm(3, 3)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement