Advertisement
Guest User

Untitled

a guest
Jul 18th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.23 KB | None | 0 0
  1. --todo:
  2. -- add function that makes sure that seeds are in the two first slots and they are a stack worth if not, will take two stacks from sorted chest
  3. -- add command in farmblock for tilling land for non fertilized
  4.  
  5.  
  6. function refuel()
  7. empty()
  8. print("refueling")
  9. if turtle.getFuelLevel() <= 500 then
  10.  
  11. print("Refueling... amt 1000")
  12. turtle.turnLeft()
  13. turtle.select(3)
  14. turtle.suck()
  15. turtle.refuel()
  16. turtle.turnLeft()
  17. turtle.drop()
  18. turtle.turnLeft()
  19. end
  20. end
  21.  
  22. function panicCorrection()
  23. local panicMode = true
  24. while panicMode do
  25. local success, data = turtle.inspect()
  26. if success then
  27. if data.name == "EnderStorage:enderChest" then
  28. print("SYSTEM PANIC! RECOVERING")
  29. turtle.turnRight()
  30. end
  31. else
  32. print("System Recovered.")
  33. panicMode = false
  34. turtle.forward()
  35. end
  36. end
  37. end
  38.  
  39.  
  40. function forward(amount)
  41. local counter = 0
  42. local amt = tonumber(amount)
  43. print("forward function")
  44. while counter < amt do
  45. turtle.forward()
  46. counter = counter + 1
  47. end
  48. end
  49.  
  50. function empty()
  51. print("Emptying..")
  52. local slots = 3
  53. while slots < 17 do
  54. print("Dropped slot ".. slots)
  55. turtle.select(slots)
  56. turtle.drop()
  57. slots = slots + 1
  58. end
  59. print("Empty COMPLETE")
  60. end
  61.  
  62. function reSeed()
  63. local functionBreak = true
  64. print("reSeed function")
  65. while functionBreak do
  66. local data = turtle.getItemDetail()
  67. print(data.name)
  68.  
  69. turtle.placeDown()
  70. functionBreak = false
  71.  
  72.  
  73. if data ~= "minecraft:carrot" then
  74. local currentSlot = turtle.getSelectedSlot()
  75. if currentSlot < 15 then
  76. turtle.select(currentSlot + 1)
  77. else
  78. turtle.select(1)
  79. end
  80. end
  81. end
  82. local success, data = turtle.inspectDown()
  83. if not success then
  84. turtle.place()
  85. end
  86. end
  87.  
  88.  
  89. function farmBlock()
  90. print("farmblock function")
  91. local success, data = turtle.inspectDown()
  92. if success then
  93. if data.name == "minecraft:carrots" then
  94. if data.metadata == 7 then
  95. print("Adult carrot Detected, Chopping and Cropping")
  96. turtle.digDown()
  97. reSeed()
  98. end
  99. end
  100. else
  101. print("No Block...")
  102. end
  103.  
  104. end
  105.  
  106. function plantBlock()
  107. print("farmblock function")
  108. local success, data = turtle.inspectDown()
  109. if success==false then
  110. print("Empty plot detected, hoeing and planting")
  111. turtle.digDown()
  112. reSeed()
  113.  
  114. else
  115. print("No Block...")
  116. end
  117.  
  118. end
  119.  
  120.  
  121. function detectDirection(currentBlock)
  122. print("Detect direction function")
  123. if (currentBlock.W % 2 == 0) then
  124. turtle.turnLeft()
  125. turtle.forward()
  126. turtle.turnLeft()
  127. else
  128.  
  129. turtle.turnRight()
  130. turtle.forward()
  131. turtle.turnRight()
  132. end
  133. end
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142. function main(xy)
  143.  
  144. local success, data = turtle.inspect()
  145. if success then
  146. if data.name == "EnderStorage:enderChest" then
  147. panicCorrection()
  148. end
  149. end
  150.  
  151. print(xy.l)
  152. print(xy.w)
  153. local length = xy.l
  154. local width = xy.w
  155. local currentBlock= {L = 0, W = 0}
  156.  
  157. while currentBlock.W < width do
  158. currentBlock.L = 0
  159. print("Here")
  160. while currentBlock.L < length do
  161. turtle.forward()
  162. if xy.bool == true then
  163. plantBlock()
  164. else
  165. farmBlock()
  166. end
  167. currentBlock.L = currentBlock.L + 1
  168. end
  169. detectDirection(currentBlock)
  170. farmBlock()
  171. currentBlock.W = currentBlock.W + 1
  172. end
  173.  
  174. local toggled = true
  175. while toggled do
  176. if (currentblockw % 2 == 0) then
  177. print("dirt detected")
  178. turtle.turnRight()
  179. forward(width)
  180. toggled=false
  181. turtle.turnLeft()
  182. turtle.forward()
  183. turtle.forward()
  184. else
  185. print("stone detected")
  186. turtle.turnLeft()
  187. forward(length)
  188. turtle.turnLeft()
  189. forward(width)
  190. turtle.forward()
  191. toggled=false
  192. end
  193. end
  194. else
  195. turtle.turnLeft()
  196.  
  197.  
  198.  
  199. turtle.turnRight()
  200. refuel()
  201. turtle.turnRight()
  202. turtle.forward()
  203. xy.bool == false
  204. main(xy)
  205. end
  206.  
  207. function startup()
  208. term.clear()
  209. print("#######################################")
  210. print("#######################################")
  211. print("#######################################")
  212. print("##########Blims Farming Turtle#########")
  213. print("#######################################")
  214. print("#######################################")
  215. print("#######################################")
  216. print("###########ver 1.2-12##################")
  217. print("#######################################")
  218. print("#######################################")
  219. print("#######################################")
  220. print("#######################################")
  221. print("#######################################")
  222. sleep(5)
  223. term.clear()
  224. local time = os.time()
  225. local formattedTime = textutils.formatTime(time, false)
  226. print("Session Time Begin: ".. formattedTime)
  227.  
  228. local xy = {l=0, w=0, bool=false}
  229. print("To begin, we need to specify the dimensions of the mining turtle...")
  230. print("Enter the length of perimeter the turtle is working:")
  231. local length = read()
  232. print("Enter the width of perimeter the turtle is working:")
  233. local width = read()
  234. print("Would you like for the first run to autoplant? (y/n):")
  235. local boole = read()
  236.  
  237. xy.l = tonumber(length)
  238. if boole = "y" then
  239. xy.bool = true
  240. else
  241. xy.bool = false
  242. end
  243. xy.w = tonumber(width)
  244.  
  245. if length == width then
  246. print("This farming turtle will work within a ".. length.. " by ".. width.. " square")
  247. print("The work area of the turtle should look like this in the example square:")
  248. print("P= plant export | T = turtle | E= empty fuel bucket | F= full fuel buckets")
  249. print("######")
  250. print("######")
  251. print("######")
  252. print("######")
  253. print("######")
  254. print("PTE###")
  255. print(" F")
  256. else
  257. print("This farming turtle will work within a ".. length.. " by ".. width.. " rectangle")
  258. print("The work area of the turtle should look like this in the example square:")
  259. print("P= plant export | T = turtle | E= empty fuel bucket | F= full fuel buckets")
  260. print("######")
  261. print("######")
  262. print("######")
  263. print("######")
  264. print("######")
  265. print("PTE###")
  266. print(" F")
  267. end
  268.  
  269. refuel()
  270. print(xy.l)
  271. print(xy.w)
  272. sleep(3)
  273. turtle.forward()
  274. main(xy)
  275. end
  276. startup()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement