Advertisement
Guest User

Untitled

a guest
Jul 18th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.58 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. 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.  
  80. turtle.placeDown()
  81.  
  82. end
  83.  
  84.  
  85. function farmBlock()
  86. print("farmblock function")
  87. local success, data = turtle.inspectDown()
  88. if success then
  89. if data.name == "minecraft:carrots" then
  90. if data.metadata == 7 then
  91. print("Adult carrot Detected, Chopping and Cropping")
  92. turtle.digDown()
  93. reSeed()
  94. end
  95. end
  96. else
  97. print("No Block...")
  98. end
  99.  
  100. end
  101.  
  102. function plantBlock()
  103. print("farmblock function")
  104. local success, data = turtle.inspectDown()
  105. if success==false then
  106. print("Empty plot detected, hoeing and planting")
  107. turtle.digDown()
  108. turtle.suckDown()
  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.suckDown()
  176. turtle.forward()
  177. turtle.suckDown()
  178. if xy.bool == true then
  179. plantBlock()
  180. else
  181. farmBlock()
  182. end
  183. currentBlock.L = currentBlock.L + 1
  184. end
  185. detectDirection(currentBlock)
  186. farmBlock()
  187. currentBlock.W = currentBlock.W + 1
  188. end
  189.  
  190. local toggled = true
  191. while toggled do
  192. if (currentBlock.W % 2 ~= 0) then
  193. print("dirt detected")
  194. turtle.turnRight()
  195. forward(width)
  196. toggled=false
  197. turtle.turnLeft()
  198. turtle.forward()
  199. turtle.forward()
  200. else
  201. print("stone detected")
  202. turtle.turnLeft()
  203. forward(length)
  204. turtle.turnLeft()
  205. forward(width)
  206. turtle.forward()
  207. toggled=false
  208. end
  209. end
  210.  
  211. turtle.turnLeft()
  212.  
  213.  
  214.  
  215. turtle.turnRight()
  216. refuel()
  217. turtle.turnRight()
  218. turtle.forward()
  219. xy.bool = false
  220. main(xy)
  221. end
  222.  
  223. function startup()
  224. term.clear()
  225. print("#######################################")
  226. print("#######################################")
  227. print("#######################################")
  228. print("##########Blims Farming Turtle#########")
  229. print("#######################################")
  230. print("#######################################")
  231. print("#######################################")
  232. print("###########ver 1.2-12##################")
  233. print("#######################################")
  234. print("#######################################")
  235. print("#######################################")
  236. print("#######################################")
  237. print("#######################################")
  238. sleep(5)
  239. term.clear()
  240. local time = os.time()
  241. local formattedTime = textutils.formatTime(time, false)
  242. print("Session Time Begin: ".. formattedTime)
  243.  
  244. local xy = {l=0, w=0, bool=false}
  245. print("To begin, we need to specify the dimensions of the mining turtle...")
  246. print("Enter the length of perimeter the turtle is working:")
  247. local length = read()
  248. print("Enter the width of perimeter the turtle is working:")
  249. local width = read()
  250. print("Would you like for the first run to autoplant? (y/n):")
  251. local boole = read()
  252.  
  253. xy.l = tonumber(length)
  254. if boole == "y" then
  255. xy.bool = true
  256. else
  257. xy.bool = false
  258. end
  259. xy.w = tonumber(width)
  260.  
  261. if length == width then
  262. print("This farming turtle will work within a ".. length.. " by ".. width.. " square")
  263. print("The work area of the turtle should look like this in the example square:")
  264. print("P= plant export | T = turtle | E= empty fuel bucket | F= full fuel buckets")
  265. print("######")
  266. print("######")
  267. print("######")
  268. print("######")
  269. print("######")
  270. print("PTE###")
  271. print(" F")
  272. else
  273. print("This farming turtle will work within a ".. length.. " by ".. width.. " rectangle")
  274. print("The work area of the turtle should look like this in the example square:")
  275. print("P= plant export | T = turtle | E= empty fuel bucket | F= full fuel buckets")
  276. print("######")
  277. print("######")
  278. print("######")
  279. print("######")
  280. print("######")
  281. print("PTE###")
  282. print(" F")
  283. end
  284.  
  285. refuel()
  286. print(xy.l)
  287. print(xy.w)
  288. sleep(3)
  289. turtle.forward()
  290. main(xy)
  291. end
  292. startup()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement