Advertisement
Tankhank

Farming Program

Dec 8th, 2021 (edited)
1,064
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.01 KB | None | 0 0
  1. local has_block, data = turtle.inspectDown()
  2. local x = 0
  3. local y = 0
  4. local facing = "north"
  5. local done = 0
  6.  
  7. local function updateY()
  8.     if facing=="north" then
  9.         y = y + 1
  10.     elseif facing=="south" then
  11.         y = y - 1
  12.     end
  13. end
  14.  
  15. while true do
  16.     has_block, data = turtle.inspectDown()
  17.     if turtle.getFuelLevel() < 50 then
  18.         turtle.select(16)
  19.         turtle.refuel()
  20.         turtle.select(1)
  21.     end
  22.     if has_block then    
  23.         if data.state.age==7 then
  24.             turtle.digDown()
  25.             turtle.placeDown()
  26.             turtle.forward()
  27.             updateY()
  28.         else
  29.             turtle.forward()
  30.             updateY()
  31.         end
  32.         done = 0
  33.     elseif done < 1 then
  34.         if facing=="north" then
  35.             turtle.turnRight()
  36.             turtle.forward()
  37.             x = x + 1
  38.             turtle.turnRight()
  39.             turtle.forward()
  40.             facing = "south"
  41.         elseif facing=="south" then
  42.             turtle.turnLeft()
  43.             turtle.forward()
  44.             x = x + 1
  45.             turtle.turnLeft()
  46.             turtle.forward()
  47.             facing = "north"
  48.         end
  49.         done = done + 1
  50.     else
  51.         updateY()
  52.         if facing=="south" then
  53.             while y > 0 do
  54.                 turtle.forward()
  55.                 y = y - 1
  56.                 turtle.turnRight()
  57.             end
  58.         end
  59.         if facing=="north" then
  60.             turtle.turnLeft()
  61.         end
  62.         while x > 0 do
  63.             turtle.forward()
  64.             x = x - 1
  65.         end
  66.         turtle.turnLeft()
  67.         turtle.forward()
  68.         for i=1,15,1 do
  69.             turtle.select(i)
  70.             turtle.drop()
  71.         end
  72.         turtle.up()
  73.         turtle.select(16)
  74.         while turtle.getItemCount() < 64 do
  75.             turtle.suck(1)
  76.         end
  77.         turtle.down()
  78.         turtle.turnRight()
  79.         turtle.turnRight()
  80.         turtle.forward()
  81.         turtle.select(1)
  82.         facing = "north"
  83.         done = 0
  84.     end    
  85. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement