Advertisement
Alfaver

Farm_wheat_fixed

Jul 10th, 2014
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.09 KB | None | 0 0
  1. -- Automatic wheat farm by Alfaver
  2.  
  3. -- Create a variable of Bone meal qty in 15th slot
  4. x = turtle.getItemCount (15)
  5.  
  6. -- Create some local function for any operation we will use
  7.  
  8. local function HarvestGo ()
  9. turtle.digDown ()
  10. turtle.forward ()
  11. end
  12.  
  13. local function HarvestLeft ()
  14. turtle.digDown ()
  15. turtle.turnLeft ()
  16. turtle.forward ()
  17. turtle.turnLeft ()
  18. end
  19.  
  20. local function HarvestRight ()
  21. turtle.digDown ()
  22. turtle.turnRight ()
  23. turtle.forward ()
  24. turtle.turnRight ()
  25. end
  26.  
  27. local function PlantGo ()
  28. turtle.select (1)
  29. turtle.placeDown ()
  30. turtle.select (14)
  31. turtle.placeDown ()
  32. turtle.forward ()
  33. end
  34.  
  35. local function PlantLeft ()
  36. turtle.select (1)
  37. turtle.placeDown ()
  38. turtle.select (14)
  39. turtle.placeDown ()
  40. turtle.turnLeft ()
  41. turtle.forward ()
  42. turtle.turnLeft ()
  43. end
  44.  
  45. local function PlantRight ()
  46. turtle.select (1)
  47. turtle.placeDown ()
  48. turtle.select (14)
  49. turtle.placeDown ()
  50. turtle.turnRight ()
  51. turtle.forward ()
  52. turtle.turnRight ()
  53. end
  54.  
  55. local function Coal ()
  56. if turtle.getFuelLevel () < 500 then
  57. turtle.up ()
  58. turtle.select (16)
  59. turtle.suck ()
  60. shell.run ("refuel 64")
  61. turtle.suck ()
  62. shell.run ("refuel 64")
  63. turtle.suck ()
  64. shell.run ("refuel 64")
  65. turtle.suck ()
  66. shell.run ("refuel 64")
  67. else
  68. sleep (1)
  69. end
  70. end
  71.  
  72. local function Bone ()
  73. turtle.select (15)
  74. if turtle.getItemCount (15) < 25 then
  75. turtle.suck ()
  76. turtle.select (16)
  77. turtle.drop ()
  78. turtle.turnRight ()
  79. turtle.turnRight ()
  80. else
  81. sleep (1)
  82. end
  83.  
  84. turtle.select (15)
  85. if turtle.getItemCount (15) < 25 then
  86. shell.run ("shutdown")
  87. else
  88. turtle.turnRight ()
  89. turtle.turnRight ()
  90. end
  91. end
  92.  
  93. -- Create a 5X5 harvest cycle with final drop of item in the 16th slot, in a front chest
  94. local function Harvest ()
  95. print ("Sto raccogliendo...")
  96.  
  97. sleep (1)
  98. HarvestGo ()
  99. HarvestGo ()
  100. HarvestGo ()
  101. HarvestGo ()
  102. HarvestRight ()
  103. HarvestGo ()
  104. HarvestGo ()
  105. HarvestGo ()
  106. HarvestGo ()
  107. HarvestLeft ()
  108. HarvestGo ()
  109. HarvestGo ()
  110. HarvestGo ()
  111. HarvestGo ()
  112. HarvestRight ()
  113. HarvestGo ()
  114. HarvestGo ()
  115. HarvestGo ()
  116. HarvestGo ()
  117. HarvestLeft ()
  118. HarvestGo ()
  119. HarvestGo ()
  120. HarvestGo ()
  121. HarvestGo ()
  122. turtle.digDown ()
  123. turtle.select (16)
  124. turtle.drop ()
  125. turtle.turnRight ()
  126. turtle.turnRight ()
  127. end
  128.  
  129. -- Create a 5X5 plant cycle with final check of fuel and nยฐof bone meal. If the fuel/bone meal level low, the turtle provide to recharge it self
  130. local function Plant ()
  131. print ("Sto piantando...")
  132.  
  133. sleep (1)
  134. PlantGo ()
  135. PlantGo ()
  136. PlantGo ()
  137. PlantGo ()
  138. PlantRight ()
  139. PlantGo ()
  140. PlantGo ()
  141. PlantGo ()
  142. PlantGo ()
  143. PlantLeft ()
  144. PlantGo ()
  145. PlantGo ()
  146. PlantGo ()
  147. PlantGo ()
  148. PlantRight ()
  149. PlantGo ()
  150. PlantGo ()
  151. PlantGo ()
  152. PlantGo ()
  153. PlantLeft ()
  154. PlantGo ()
  155. PlantGo ()
  156. PlantGo ()
  157. PlantGo ()
  158. turtle.select (1)
  159. turtle.placeDown ()
  160. turtle.select (13)
  161. turtle.placeDown ()
  162. end
  163.  
  164. -- Create an false infinity loop. False because if the aren't enough bone meal also after the refill, the turtle should turn off
  165. while true do
  166. Harvest ()
  167. Plant ()
  168. Coal ()
  169. Bone ()
  170. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement