Advertisement
eniallator

Crop Farmer

Dec 30th, 2020 (edited)
915
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.51 KB | None | 0 0
  1. local farmSideLength = 5
  2. local inspectAttempts = 5
  3. local desiredFuelPercent = 0.5
  4.  
  5. local function forward()
  6.     while not turtle.forward() do
  7.         turtle.dig()
  8.     end
  9. end
  10.  
  11. local function checkDown(name)
  12.     local i
  13.     for i = 1, inspectAttempts do
  14.         local success, blockData = turtle.inspectDown()
  15.         if success then
  16.             return blockData.name:find(name) ~= nil
  17.         end
  18.     end
  19. end
  20.  
  21. while true do
  22.     turtle.select(1)
  23.  
  24.     forward()
  25.     forward()
  26.     turtle.turnRight()
  27.     turtle.placeDown()
  28.  
  29.     local i, j
  30.     for i = 1, farmSideLength do
  31.         for j = 2, farmSideLength do
  32.             forward()
  33.             turtle.placeDown()
  34.         end
  35.         if i < farmSideLength then
  36.             if i % 2 == 1 then
  37.                 turtle.turnLeft()
  38.                 forward()
  39.                 turtle.placeDown()
  40.                 turtle.turnLeft()
  41.             else
  42.                 turtle.turnRight()
  43.                 forward()
  44.                 turtle.placeDown()
  45.                 turtle.turnRight()
  46.             end
  47.         end
  48.     end
  49.  
  50.     for i = 1, 2 do
  51.         turtle.turnRight()
  52.         for j = 2, farmSideLength do
  53.             forward()
  54.         end
  55.     end
  56.  
  57.     forward()
  58.     forward()
  59.     if
  60.         turtle.getFuelLevel() ~= 'unlimited' and checkDown('pedestal') and
  61.             turtle.getFuelLevel() < turtle.getFuelLimit() * desiredFuelPercent
  62.      then
  63.         turtle.select(16)
  64.         turtle.suckDown()
  65.         turtle.refuel()
  66.     end
  67.     sleep(60)
  68. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement