Advertisement
kreezxil

Wheat Autoharvester v1.0.3

Oct 6th, 2013
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Wheat farming turtle by Razputin
  2. -- Modified and bugfixed by Pugnacious
  3. -- Optimized and cleaned up by Kreezxil 10/6/2013
  4.  
  5. --[Code for the turtle to leave start position and go to farming level]--
  6. function start()
  7.    turtle.forward()
  8.    turtle.down()
  9.    turtle.down()
  10. end
  11.  
  12. -- rewrote this function to be extensible and to eliminate the m7
  13. function move(i)
  14.    for j=1,i do
  15.       turtle.forward()
  16.    end
  17. end
  18.  
  19. --[Down Command]--
  20. function down()
  21.    turtle.down()
  22. end
  23.  
  24. --[Code for the turtle to return toward start position]--
  25. function returnTurtle()
  26.    move(7)
  27.    turtle.up()
  28. end
  29.  
  30. --[Planting code]--
  31. function plant()
  32.    turtle.digDown()
  33.    turtle.placeDown()
  34. end
  35.  
  36. --[Code for returning turn depending on the 'tray' you end on. Odd/even]--
  37. function returningLeftTurn()
  38.    turtle.turnLeft()
  39.    turtle.up()
  40.    turtle.up()
  41. end
  42.  
  43. --[Ditto]--
  44. function returningRightTurn()
  45.    turtle.turnRight()
  46.    turtle.up()
  47.    turtle.up()
  48. end
  49.  
  50. --[For turning at the end of each row of plots. Odd/even]--
  51. function leftTurn()
  52.    turtle.turnLeft()
  53.    turtle.forward()
  54.    turtle.turnLeft()
  55. end
  56.  
  57. --[Ditto]--
  58. function rightTurn()
  59.    turtle.turnRight()
  60.    turtle.forward()
  61.    turtle.turnRight()
  62. end
  63.  
  64. --[Function for each row of plots]--
  65. function row()
  66.    for i=1,5 do
  67.       plant()
  68.       move()
  69.    end
  70.    plant()
  71. end
  72.  
  73.  
  74. --['Tray' -the body.]--
  75. -- by kreezxil to make trayOdd() and trayEven() more readable
  76.  
  77. function trayBody()
  78.    turtle.refuel()
  79.  
  80.    for i=1,3 do
  81.       row()
  82.       rightTurn()
  83.       row()
  84.       leftTurn()
  85.    end
  86.  
  87. end
  88.  
  89. --['Tray' odd.]--
  90. -- Added a refuel for those of us who require fuel
  91.  
  92. function trayOdd()
  93.    trayBody()
  94.    row()
  95.    rightTurn()
  96.   down()
  97. end
  98.  
  99. --['Tray' even]--
  100. -- Added a refuel for those of us who require fuel
  101.  
  102. function trayEven()
  103.    trayBody()
  104.    row()
  105.    leftTurn()
  106.   down()
  107. end
  108.  
  109. --[Start of the executable part of program]--
  110. -- Added refuel and set the order of inventory selections.
  111. -- Inventory box 1 is for fuel and the rest is for seeds.
  112.  
  113. turtle.refuel()
  114. start()
  115. turtle.select (2)
  116. trayOdd()
  117. turtle.select(3)
  118. trayEven()
  119. turtle.select(4)
  120. trayOdd()
  121. turtle.select(5)
  122. trayEven()
  123. returningLeftTurn()
  124. returnTurtle()
  125. returnTurtle()
  126. returnTurtle()
  127. move(7)
  128. turtle.turnRight()
  129. turtle.back()
  130. turtle.up()
  131. turtle.up()
  132. turtle.back()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement