Advertisement
Guest User

Untitled

a guest
Jul 18th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.57 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. data = turtle.getItemDetail()
  67. if data == nil then
  68. local currentSlot = turtle.getSelectedSlot()
  69. if currentSlot < 15 then
  70. turtle.select(currentSlot + 1)
  71. else
  72. turtle.select(1)
  73. end
  74.  
  75. else
  76. functionBreak = false
  77. end
  78. end
  79. local success, data = turtle.inspectDown()
  80. if not success then
  81. turtle.place()
  82. end
  83. end
  84.  
  85.  
  86. function farmBlock()
  87. print("farmblock function")
  88. local success, data = turtle.inspectDown()
  89. if success then
  90. if data.name == "minecraft:carrots" then
  91. if data.metadata == 7 then
  92. print("Adult carrot Detected, Chopping and Cropping")
  93. turtle.digDown()
  94. reSeed()
  95. end
  96. end
  97. else
  98. print("No Block...")
  99. end
  100.  
  101. end
  102.  
  103. function plantBlock()
  104. print("farmblock function")
  105. local success, data = turtle.inspectDown()
  106. if success==false then
  107. print("Empty plot detected, hoeing and planting")
  108. turtle.digDown()
  109. turtle.placeDown()
  110.  
  111. else
  112. print("No Block...")
  113. end
  114. local functionBreak = true
  115. print("reSeed function")
  116. while functionBreak do
  117. data = turtle.getItemDetail()
  118. if data == nil then
  119. local currentSlot = turtle.getSelectedSlot()
  120. if currentSlot < 15 then
  121. turtle.select(currentSlot + 1)
  122. else
  123. turtle.select(1)
  124. end
  125.  
  126. else
  127. functionBreak = false
  128. end
  129. end
  130. turtle.placeDown()
  131.  
  132. end
  133.  
  134.  
  135. function detectDirection(currentBlock)
  136. print("Detect direction function")
  137. if (currentBlock.W % 2 ~= 0) then
  138. turtle.turnLeft()
  139. turtle.forward()
  140. turtle.turnLeft()
  141. else
  142.  
  143. turtle.turnRight()
  144. turtle.forward()
  145. turtle.turnRight()
  146. end
  147. end
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156. function main(xy)
  157.  
  158. local success, data = turtle.inspect()
  159. if success then
  160. if data.name == "EnderStorage:enderChest" then
  161. panicCorrection()
  162. end
  163. end
  164.  
  165. print(xy.l)
  166. print(xy.w)
  167. local length = tonumber(xy.l)
  168. local width = tonumber(xy.w)
  169. local currentBlock= {L = 0, W = 0}
  170.  
  171. while currentBlock.W < width do
  172. currentBlock.L = 0
  173. print("Here")
  174. while currentBlock.L < length do
  175. turtle.forward()
  176. if xy.bool == true then
  177. plantBlock()
  178. else
  179. farmBlock()
  180. end
  181. currentBlock.L = currentBlock.L + 1
  182. end
  183. detectDirection(currentBlock)
  184. farmBlock()
  185. currentBlock.W = currentBlock.W + 1
  186. end
  187.  
  188. local toggled = true
  189. while toggled do
  190. if (currentblockw % 2 ~= 0) then
  191. print("dirt detected")
  192. turtle.turnRight()
  193. forward(width)
  194. toggled=false
  195. turtle.turnLeft()
  196. turtle.forward()
  197. turtle.forward()
  198. else
  199. print("stone detected")
  200. turtle.turnLeft()
  201. forward(length)
  202. turtle.turnLeft()
  203. forward(width)
  204. turtle.forward()
  205. toggled=false
  206. end
  207. end
  208.  
  209. turtle.turnLeft()
  210.  
  211.  
  212.  
  213. turtle.turnRight()
  214. refuel()
  215. turtle.turnRight()
  216. turtle.forward()
  217. xy.bool = false
  218. main(xy)
  219. end
  220.  
  221. function startup()
  222. term.clear()
  223. print("#######################################")
  224. print("#######################################")
  225. print("#######################################")
  226. print("##########Blims Farming Turtle#########")
  227. print("#######################################")
  228. print("#######################################")
  229. print("#######################################")
  230. print("###########ver 1.2-12##################")
  231. print("#######################################")
  232. print("#######################################")
  233. print("#######################################")
  234. print("#######################################")
  235. print("#######################################")
  236. sleep(5)
  237. term.clear()
  238. local time = os.time()
  239. local formattedTime = textutils.formatTime(time, false)
  240. print("Session Time Begin: ".. formattedTime)
  241.  
  242. local xy = {l=0, w=0, bool=false}
  243. print("To begin, we need to specify the dimensions of the mining turtle...")
  244. print("Enter the length of perimeter the turtle is working:")
  245. local length = read()
  246. print("Enter the width of perimeter the turtle is working:")
  247. local width = read()
  248. print("Would you like for the first run to autoplant? (y/n):")
  249. local boole = read()
  250.  
  251. xy.l = tonumber(length)
  252. if boole == "y" then
  253. xy.bool = true
  254. else
  255. xy.bool = false
  256. end
  257. xy.w = tonumber(width)
  258.  
  259. if length == width then
  260. print("This farming turtle will work within a ".. length.. " by ".. width.. " square")
  261. print("The work area of the turtle should look like this in the example square:")
  262. print("P= plant export | T = turtle | E= empty fuel bucket | F= full fuel buckets")
  263. print("######")
  264. print("######")
  265. print("######")
  266. print("######")
  267. print("######")
  268. print("PTE###")
  269. print(" F")
  270. else
  271. print("This farming turtle will work within a ".. length.. " by ".. width.. " rectangle")
  272. print("The work area of the turtle should look like this in the example square:")
  273. print("P= plant export | T = turtle | E= empty fuel bucket | F= full fuel buckets")
  274. print("######")
  275. print("######")
  276. print("######")
  277. print("######")
  278. print("######")
  279. print("PTE###")
  280. print(" F")
  281. end
  282.  
  283. refuel()
  284. print(xy.l)
  285. print(xy.w)
  286. sleep(3)
  287. turtle.forward()
  288. main(xy)
  289. end
  290. startup()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement