Advertisement
M0n5t3r

Untitled

Jun 5th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.14 KB | None | 0 0
  1. local DayNightCycle = 1200
  2.  
  3. local steps = 0
  4. local rowsDone = 0
  5.  
  6. local length = 14
  7. local width = 4
  8. local strokes = 3
  9.  
  10. local seedsPlanted = 0
  11. local rowsMade = 0
  12. local timesBusy = 0
  13.  
  14. function firstStartup()
  15. if turtle.getItemCount(1) < 1 then
  16. print("put deeds in slot 1!")
  17. repeat
  18. sleep (1.1)
  19.  
  20. until turtle.getItemCount(1) > 1
  21. end
  22. if turtle.getItemCount(2) < 1 then
  23. print("put seeds in slot 2!")
  24. repeat
  25. sleep (1.1)
  26. until turtle.getItemCount(2) >= 1
  27. end
  28. end
  29.  
  30. function harvest()
  31. local success, t = turtle.inspectDown()
  32. if success then
  33. if t.name == "minecraft:dirt" then
  34. turtle.digDown()
  35. end
  36. if t.metadata == 7 then
  37. if turtle.getItemCount(1) > 2 then
  38. turtle.select(1)
  39. turtle.digDown()
  40. turtle.placeDown()
  41. seedsPlanted = seedsPlanted + 1
  42. elseif turtle.getItemCount(2) > 2 then
  43. turtle.select(2)
  44. turtle.digDown()
  45. turtle.placeDown()
  46. seedsPlanted = seedsPlanted + 1
  47. else
  48. print("Need new seeds ...")
  49. turtle.select(1)
  50. turtle.digDown()
  51. end
  52. end
  53. else
  54. turtle.digDown()
  55. if turtle.getItemCount(2) > 2 then
  56. turtle.select(2)
  57. turtle.placeDown()
  58. seedsPlanted = seedsPlanted + 1
  59. elseif turtle.getItemCount(1) > 2 then
  60. turtle.select(1)
  61. turtle.placeDown()
  62. seedsPlanted = seedsPlanted + 1
  63. else
  64. print("Need new seeds ...")
  65. end
  66. end
  67. end
  68.  
  69. function startFromChest()
  70. steps = 0
  71. if rowsDone == 0 then
  72. turtle.forward()
  73. turtle.down()
  74. turtle.down()
  75. elseif rowsDone == 1 then
  76. turtle.forward()
  77. turtle.down()
  78. turtle.down()
  79. turtle.turnRight()
  80. repeat
  81. turtle.forward()
  82. steps = steps + 1
  83. until steps == 5
  84. turtle.turnLeft()
  85. elseif rowsDone == 2 then
  86. turtle.forward()
  87. turtle.down()
  88. turtle.down()
  89. turtle.turnRight()
  90. repeat
  91. turtle.forward()
  92. steps = steps + 1
  93. until steps == 10
  94. turtle.turnLeft()
  95. end
  96. steps = 0
  97. oneRowHarvest()
  98. end
  99.  
  100. function oneRowHarvest()
  101. steps = 0
  102.  
  103. repeat
  104. harvest()
  105. turtle.forward()
  106. steps = steps + 1
  107. until steps == length
  108.  
  109. steps = 0
  110.  
  111. harvest()
  112. turtle.turnRight()
  113. turtle.forward()
  114. turtle.turnRight()
  115.  
  116. repeat
  117. harvest()
  118. turtle.forward()
  119. steps = steps + 1
  120. until steps == length
  121.  
  122. steps = 0
  123.  
  124. harvest()
  125. turtle.turnLeft()
  126. turtle.forward()
  127. turtle.turnLeft()
  128.  
  129. repeat
  130. harvest()
  131. turtle.forward()
  132. steps = steps + 1
  133. until steps == length
  134.  
  135. steps = 0
  136.  
  137. harvest()
  138. turtle.turnRight()
  139. turtle.forward()
  140. turtle.turnRight()
  141.  
  142. repeat
  143. harvest()
  144. turtle.forward()
  145. steps = steps + 1
  146. until steps == length
  147.  
  148. harvest()
  149. steps = 0
  150.  
  151. rowsDone = rowsDone + 1
  152.  
  153. rowsMade = rowsMade + 1
  154.  
  155. emptyInv()
  156.  
  157. end
  158.  
  159. -- empty inventory & seeds
  160. function emptyInv()
  161. turtle.turnRight()
  162. steps = 0
  163. if rowsDone == 1 then
  164. repeat
  165. turtle.forward()
  166. steps = steps + 1
  167. until steps == 4
  168. elseif rowsDone == 2 then
  169. repeat
  170. turtle.forward()
  171. steps = steps + 1
  172. until steps == 9
  173. elseif rowsDone == 3 then
  174. repeat
  175. turtle.forward()
  176. steps = steps + 1
  177. until steps == 14
  178. end
  179.  
  180. steps = 0
  181.  
  182. turtle.turnRight()
  183. turtle.up()
  184. turtle.up()
  185. turtle.back()
  186.  
  187. for q=3,16 do
  188. turtle.select(q)
  189. turtle.dropDown()
  190. end
  191.  
  192. if turtle.getItemCount(2) > 32 then
  193. print("empty seeds")
  194. turtle.turnRight()
  195. repeat
  196. turtle.forward()
  197. steps = steps + 1
  198. until steps == 12
  199.  
  200. steps = 0
  201.  
  202. for q=1,2 do
  203. print("empty now")
  204. turtle.select(q)
  205. repeat
  206. turtle.dropDown(1)
  207. until turtle.getItemCount(q) <= 5
  208. end
  209.  
  210. repeat
  211. turtle.back()
  212. steps = steps + 1
  213. until steps == 12
  214. steps = 0
  215.  
  216. turtle.turnLeft()
  217. end
  218.  
  219. if rowsDone == 3 then
  220. rowsDone = 0
  221. timesBusy = timesBusy + 1
  222. sleepFunction()
  223. end
  224. end
  225.  
  226. function sleepFunction()
  227. print("Going to sleep")
  228. local slept = 0
  229. repeat
  230. sleep(50)
  231. slept = slept + 50
  232. print("Slept: " .. slept)
  233. until slept > DayNightCycle
  234. print( "gotte work ")
  235. end
  236.  
  237. firstStartup()
  238. while true do
  239. print("Times done = " .. timesBusy)
  240. print("Seeds planted = " .. seedsPlanted)
  241. print("Rows made = " .. rowsMade)
  242. startFromChest()
  243. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement