AKopyl

Farm

Mar 17th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.31 KB | None | 0 0
  1. local arg = {...}
  2.  
  3. local crop = arg[1]
  4. local timeout = 800
  5. local cycles = 0
  6. local length = 0
  7. local travel = 0
  8.  
  9. while true do
  10.     local success, data = turtle.inspectDown()
  11.  
  12.     if data.state ~= nil then
  13.         if data.name == 'minecraft:stone' then
  14.             turtle.turnRight()
  15.         end
  16.  
  17.         if data.name == 'minecraft:planks' then
  18.             turtle.turnLeft()
  19.         end
  20.  
  21.         if data.name == 'minecraft:stonebrick' then
  22.             print('Found a stone block! Unloading and sleeping '..timeout..' seconds...')
  23.             if turtle.detectUp() then
  24.                 for n = 3, 16, 1 do
  25.                     turtle.select(n)
  26.                     turtle.dropUp()
  27.                 end
  28.             end
  29.             sleep(timeout)
  30.             cycles = cycles + 1
  31.             length = math.max(length, travel)
  32.             print (cycles..' CYCLE')
  33.             if turtle.getItemCount(1) < length/80 then
  34.                 print('Waiting for fuel')
  35.             end
  36.             while turtle.getItemCount(1) < length/80 do
  37.                 sleep(1)
  38.             end
  39.         end
  40.  
  41.         if data.state.age == 7 then
  42.             print('Found a grown crop! Harvesting...')
  43.             turtle.digDown('right')
  44.         end
  45.     end
  46.  
  47.     if not turtle.detectDown() then
  48.         print('Is this an empty spot? Tilling and replanting...')
  49.         turtle.digDown('right')
  50.         turtle.select(2)
  51.         turtle.placeDown()
  52.     end
  53.  
  54.     if turtle.getFuelLevel() < 1 then
  55.         print('Out of fuel! Refuelling...')
  56.         turtle.select(1)
  57.         turtle.refuel(1)
  58.     end
  59.    
  60.     turtle.forward()
  61.     travel = travel + 1
  62. end
Add Comment
Please, Sign In to add comment