SHARE
TWEET

Untitled

a guest Jul 18th, 2019 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.             end
  114.         end
  115.     else
  116.     print("No Block...")
  117.     end
  118.    
  119. end
  120.  
  121.  
  122. function detectDirection(currentBlock)
  123. print("Detect direction function")
  124. if (currentBlock.W % 2 == 0) then
  125.         turtle.turnLeft()
  126.         turtle.forward()
  127.         turtle.turnLeft()
  128.         else
  129.  
  130.         turtle.turnRight()
  131.         turtle.forward()
  132.         turtle.turnRight()
  133.         end
  134.     end
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143. function main(xy)
  144.  
  145.  local success, data = turtle.inspect()
  146.     if success then
  147.     if data.name == "EnderStorage:enderChest" then
  148.         panicCorrection()
  149.         end
  150.         end
  151.  
  152. print(xy.l)
  153. print(xy.w)
  154. local length = xy.l
  155. local width = xy.w
  156. local currentBlock= {L = 0, W = 0}
  157.  
  158. while currentBlock.W < width do
  159. currentBlock.L = 0
  160. print("Here")
  161.     while currentBlock.L < length do
  162.         turtle.forward()
  163.         if xy.bool == true then
  164.         plantBlock()
  165.         else
  166.         farmBlock()
  167.         end
  168.         currentBlock.L = currentBlock.L + 1
  169.     end
  170.     detectDirection(currentBlock)
  171.     farmBlock()
  172.     currentBlock.W = currentBlock.W + 1
  173. end
  174.  
  175. local toggled = true
  176. while toggled do
  177. if (currentblockw % 2 == 0) then
  178.         print("dirt detected")
  179.             turtle.turnRight()
  180.             forward(width)
  181.             toggled=false
  182.             turtle.turnLeft()
  183.             turtle.forward()
  184.             turtle.forward()
  185.         else
  186.             print("stone detected")
  187.                 turtle.turnLeft()
  188.                 forward(length)
  189.                 turtle.turnLeft()
  190.                 forward(width)
  191.                 turtle.forward()
  192.                 toggled=false
  193.         end
  194.         end
  195.         else
  196.         turtle.turnLeft()
  197.        
  198.    
  199.    
  200.     turtle.turnRight()
  201.     refuel()
  202.     turtle.turnRight()
  203.     turtle.forward()
  204.     xy.bool == false
  205.     main(xy)
  206. end
  207.  
  208. function startup()
  209. term.clear()
  210. print("#######################################")
  211. print("#######################################")
  212. print("#######################################")
  213. print("##########Blims Farming Turtle#########")
  214. print("#######################################")
  215. print("#######################################")
  216. print("#######################################")
  217. print("###########ver 1.2-12##################")
  218. print("#######################################")
  219. print("#######################################")
  220. print("#######################################")
  221. print("#######################################")
  222. print("#######################################")
  223. sleep(5)
  224. term.clear()
  225. local time = os.time()
  226. local formattedTime = textutils.formatTime(time, false)
  227. print("Session Time Begin: ".. formattedTime)
  228.  
  229. local xy = {l=0, w=0, bool=false}
  230. print("To begin, we need to specify the dimensions of the mining turtle...")
  231. print("Enter the length of perimeter the turtle is working:")
  232. local length = read()
  233. print("Enter the width of perimeter the turtle is working:")
  234. local width = read()
  235. print("Would you like for the first run to autoplant? (y/n):")
  236. local boole = read()
  237.  
  238. xy.l = tonumber(length)
  239. if boole = "y" then
  240. xy.bool = true
  241. else
  242. xy.bool = false
  243. end
  244. xy.w = tonumber(width)
  245.  
  246. if length == width then
  247. print("This farming turtle will work within a ".. length.. " by ".. width.. " square")
  248. print("The work area of the turtle should look like this in the example square:")
  249. print("P= plant export | T = turtle | E= empty fuel bucket | F= full fuel buckets")
  250. print("######")
  251. print("######")
  252. print("######")
  253. print("######")
  254. print("######")
  255. print("PTE###")
  256. print(" F")
  257. else
  258. print("This farming turtle will work within a ".. length.. " by ".. width.. " rectangle")
  259. print("The work area of the turtle should look like this in the example square:")
  260. print("P= plant export | T = turtle | E= empty fuel bucket | F= full fuel buckets")
  261. print("######")
  262. print("######")
  263. print("######")
  264. print("######")
  265. print("######")
  266. print("PTE###")
  267. print(" F")
  268. end
  269.  
  270. refuel()
  271. print(xy.l)
  272. print(xy.w)
  273. sleep(3)
  274. turtle.forward()
  275. main(xy)
  276. end
  277. startup()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top