PancakePhD

Untitled

Apr 20th, 2021 (edited)
581
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local function checkBlock()
  2.     isBlockDown, blockDown = turtle.inspectDown()
  3.      
  4.     if isBlockDown and (blockDown.name == "minecraft:wheat" or blockDown.name == "minecraft:carrots") and blockDown.state.age == 7 then
  5.         turtle.digDown()
  6.         turtle.suckDown()
  7.     end
  8.    
  9.     if (blockDown.name == "minecraft:carrots") then
  10.         turtle.select(3)
  11.     else
  12.         turtle.select(2)
  13.     end
  14.     turtle.placeDown()
  15. end
  16.  
  17. local function refuel()
  18.     turtle.select(16)
  19.  
  20.     if turtle.getFuelLevel() < 100 then
  21.         --if turtle.getItemCount(1) < 8 then
  22.             --turtle.turnLeft()
  23.             --turtle.suck(56)
  24.         --end
  25.        
  26.         turtle.refuel()
  27.     end
  28.    
  29.     os.setComputerLabel("Farming. Fuel: "..turtle.getFuelLevel())
  30. end
  31.  
  32. local function harvest()
  33.  for i=1,4 do
  34.         for j=1,6 do
  35.             turtle.forward()
  36.             checkBlock()
  37.             refuel()
  38.         end
  39.  
  40.         if i % 2 ~= 0 then
  41.             turtle.turnRight()
  42.             turtle.forward()
  43.             checkBlock()
  44.             turtle.turnRight()
  45.         elseif i % 4 == 0 then
  46.             turtle.turnLeft()
  47.             turtle.forward()
  48.             turtle.forward()
  49.             turtle.turnLeft()
  50.             checkBlock()
  51.         else
  52.             turtle.turnLeft()
  53.             turtle.forward()
  54.             turtle.turnLeft()
  55.             checkBlock()
  56.         end
  57.     end
  58. end
  59.  
  60. local function deposit()
  61.     isBlock, block = turtle.inspectDown()
  62.  
  63.     if isBlock and block.name == "minecraft:chest" then
  64.         for i=1,15 do
  65.             turtle.select(i)
  66.            
  67.             item = turtle.getItemDetail()
  68.  
  69.             if item then
  70.                 count = item.count
  71.            
  72.                 if i == 2 or i == 3 then
  73.                     count = count - 4
  74.                 end
  75.  
  76.                 if count > 0 then
  77.                     turtle.dropDown(count)
  78.                 end
  79.             end
  80.         end
  81.     end
  82. end
  83.  
  84. local function main()
  85.     while true do
  86.         for i=1,2 do
  87.             harvest()
  88.         end
  89.  
  90.         turtle.back()
  91.         turtle.turnLeft()
  92.  
  93.         for i=1,10 do
  94.             turtle.forward()
  95.         end
  96.  
  97.         turtle.turnRight()
  98.         turtle.forward()
  99.  
  100.         deposit()
  101.  
  102.         for i=1,480 do
  103.             os.setComputerLabel("Waiting "..480-i.." seconds")
  104.             sleep(1)
  105.         end
  106.     end
  107. end
  108.  
  109. main()
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×