Advertisement
Guest User

Untitled

a guest
Apr 25th, 2015
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.62 KB | None | 0 0
  1. tArgs = { ... }
  2. print("Farming in progress...")
  3.  
  4.  
  5.  
  6.  
  7.  
  8. --Assume the turtle has started at the chest facing the wheat
  9. while true do
  10.  
  11.  
  12. if turtle.getFuelLevel() < 500 then
  13. print("Fuel level low, returning to base...")
  14. --Refueling code here
  15. end
  16.  
  17.  
  18. turtle.forward()
  19.  
  20. turtle.up()
  21. turtle.forward()
  22. turtle.forward()
  23. turtle.forward()
  24. turtle.forward()
  25. turtle.forward()
  26. turtle.turnLeft()
  27. turtle.forward()
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34. --Wheat row 1 & 2 & carrot row 1
  35. for i=1,3 do
  36. if i>=2 then
  37. k = 1
  38. else
  39. k = 0
  40. end
  41. for j=0,(11+k) do
  42. local success, data = turtle.inspectDown()
  43.  
  44. if success then
  45. if (tonumber(data.metadata) >= 7) then
  46. turtle.digDown()
  47. turtle.suckDown()
  48. turtle.digDown()
  49. if i<3 then
  50. if assert(loadfile("inv_search"))("minecraft:wheat_seeds") then
  51. turtle.placeDown()
  52. end
  53. else
  54. if assert(loadfile("inv_search"))("minecraft:carrot") then
  55. turtle.placeDown()
  56. end
  57. end
  58. end
  59. else
  60. turtle.digDown()
  61. --Call select item subroutine
  62. turtle.placeDown()
  63. end
  64.  
  65. turtle.forward()
  66. end
  67. if i==3 then
  68. turtle.turnLeft()
  69. print(turtle.forward())
  70. os.sleep(0.1)
  71. print(turtle.forward())
  72. print("OHSHIT")
  73. turtle.turnLeft()
  74. break
  75. end
  76. if (i % 2)~=0 then
  77. turtle.turnLeft()
  78. turtle.forward()
  79. print("LEFT")
  80. turtle.forward()
  81. turtle.turnLeft()
  82. else
  83. turtle.turnRight()
  84. turtle.forward()
  85. print("RIGHT")
  86. turtle.forward()
  87. turtle.turnRight()
  88. end
  89. end
  90.  
  91. --Melon row
  92. turtle.forward()
  93. for i=1,2 do
  94. for j=1,4 do
  95. local success, data = turtle.inspectDown()
  96.  
  97. if success then
  98. if data.name == 'minecraft:melon_block' then
  99. turtle.digDown()
  100. turtle.suckDown()
  101. turtle.digDown()
  102. end
  103. end
  104.  
  105. turtle.forward()
  106.  
  107. end
  108. if i==1 then
  109. turtle.turnLeft()
  110. turtle.forward()
  111. turtle.turnRight()
  112. turtle.forward()
  113. turtle.forward()
  114. turtle.forward()
  115. turtle.forward()
  116. turtle.turnRight()
  117. turtle.forward()
  118. turtle.turnLeft()
  119. else
  120. turtle.forward()
  121. turtle.turnRight()
  122. turtle.forward()
  123. turtle.forward()
  124. turtle.turnRight()
  125. end
  126. end
  127.  
  128.  
  129. --Carrot row 2 & potato rows 1 & 2
  130. for i=1,3 do
  131. if i~=3 then
  132. k = 2
  133. else
  134. k = 0
  135. end
  136. for j=0,(11+k) do
  137. local success, data = turtle.inspectDown()
  138.  
  139. if success then
  140. if (tonumber(data.metadata) >= 7) then
  141. turtle.digDown()
  142. turtle.suckDown()
  143. turtle.digDown()
  144. if i==1 then
  145. if assert(loadfile("inv_search"))("minecraft:carrot") then
  146. turtle.placeDown()
  147. end
  148. else
  149. if assert(loadfile("inv_search"))("minecraft:potato") then
  150. turtle.placeDown()
  151. end
  152. end
  153. end
  154. else
  155. turtle.digDown()
  156. --Call select item subroutine
  157. turtle.placeDown()
  158. end
  159.  
  160. turtle.forward()
  161. end
  162. if i==3 then
  163. turtle.turnRight()
  164. turtle.turnRight()
  165. for l=1,13 do
  166. turtle.forward()
  167. end
  168. turtle.turnLeft()
  169. turtle.forward()
  170. turtle.forward()
  171. turtle.down()
  172. turtle.forward()
  173. turtle.forward()
  174. turtle.forward()
  175. turtle.forward()
  176. break
  177. end
  178. if (i % 2)~=0 then
  179. turtle.turnLeft()
  180. turtle.forward()
  181. turtle.forward()
  182. turtle.turnLeft()
  183. else
  184. turtle.turnRight()
  185. turtle.forward()
  186. turtle.forward()
  187. turtle.turnRight()
  188. end
  189. end
  190.  
  191. --Drop off food & send message to greenhouse controller
  192. print("Farming complete! Going to sleep for a bit...")
  193. assert(loadfile("inv_search"))("minecraft:potato")
  194. turtle.dropUp(turtle.getItemCount()-2)
  195. assert(loadfile("inv_search"))("minecraft:carrot")
  196. turtle.dropUp(turtle.getItemCount()-2)
  197. assert(loadfile("inv_search"))("minecraft:wheat")
  198. turtle.dropUp(turtle.getItemCount())
  199. assert(loadfile("inv_search"))("minecraft:melon")
  200. turtle.dropUp(turtle.getItemCounter())
  201. assert(loadfile("inv_search"))("minecraft:wheat_seeds")
  202. turtle.dropUp(turtle.getItemCounter())
  203. os.sleep(20)
  204. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement