Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
160
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.turnRight()
  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. turtle.turnRight()
  34. turtle.turnRight()
  35. end
  36.  
  37. function nineXNine(targetLength, targetWidth)
  38.  
  39. for width = 1, targetWidth, 1 do
  40. processLine(targetLength)
  41.  
  42. if width == targetWidth then
  43. goHome(targetLength, targetWidth)
  44. elseif width%2 == 1 then
  45. turnRight()
  46. nextMoveIsRight = false
  47. else
  48. turnLeft()
  49. nextMoveIsRight = true
  50. end
  51. end
  52. end
  53.  
  54. function processLine(targetLength)
  55. doWork()
  56. for length = 1, targetLength-1, 1 do
  57. turtle.forward()
  58. doWork()
  59. end
  60. end
  61.  
  62. function doWork()
  63. selectSeeds()
  64. turtle.digDown()
  65. turtle.placeDown()
  66. end
  67.  
  68. function selectSeeds()
  69. local data = turtle.getItemDetail()
  70. if data then
  71. print("Item name: ", data.name)
  72. end
  73. end
  74.  
  75. function turnRight()
  76. turtle.turnRight()
  77. turtle.forward()
  78. turtle.turnRight()
  79. end
  80.  
  81. function turnLeft()
  82. turtle.turnLeft()
  83. turtle.forward()
  84. turtle.turnLeft()
  85. end
  86.  
  87. function turnAround()
  88. turtle.turnLeft()
  89. turtle.turnLeft()
  90. end
  91.  
  92. function goForward(lengthToGo)
  93. for lengthWent = 1, lengthToGo, 1 do
  94. turtle.forward()
  95. end
  96. end
  97.  
  98. function goHome(targetLength, targetWidth)
  99. if(targetWidth%2 == 1) then
  100. turnAround()
  101. goForward(targetLength-1)
  102. end
  103.  
  104. turtle.turnRight()
  105. goForward(targetWidth-1)
  106. turtle.turnRight()
  107. end
  108.  
  109. farm(3, 3)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement