Advertisement
Guest User

staniv2

a guest
Apr 4th, 2020
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.50 KB | None | 0 0
  1. x = tArgs[1]
  2. y = tArgs[2]
  3.  
  4. function fSubforward()
  5.   repeat
  6.     bGo = turtle.forward()
  7.     if bGo == false then
  8.       if turtle.getFuelLevel() == 0 then
  9.         print('Out of fuel. checking for fuel now...')
  10.         repeat
  11.           bFuel = turtle.refuel()
  12.           sleep(1)
  13.         until bFuel == true
  14.       elseif turtle.detect() == true then
  15.         print("...that block isn't supposed to be there. Move it out of my way to continue farming.")
  16.         repeat
  17.           bBlock = turtle.detect()
  18.           sleep(1)
  19.         until bBlock == false
  20.       else
  21.         print("Could not diagnose movement issue. Terminating with error.")
  22.         error("Forward Issue Diagnostic failure")
  23.       end
  24.     end
  25.   until bGo == true
  26. end
  27. function fSscan()
  28.   for i = 1, 15 do
  29.     tData = turtle.getItemDetail(i)
  30.     if tData.name == "minecraft:wheat" then
  31.       if i == 1 then
  32.         turtle.select(1)
  33.         for j = 2, 15 do
  34.           tSdata = turtle.getItemDetail(j)
  35.           nCnt = turtle.getItemCount(j)
  36.           if nCnt == 0 or tSdata.name == tData.name and nCnt+turtle.getItemCount() < 64 then
  37.             turtle.transferTo(j)
  38.             break
  39.           end
  40.         end
  41.       end
  42.       turtle.select(i)
  43.     else
  44.       turtle.select(i)
  45.       turtle.transferTo(1)
  46.       turtle.select(1)
  47.       break
  48.     end
  49.   end
  50. end
  51. function fSforward()
  52.   _, tMeta = turtle.inspectDown()
  53.   if tMeta.metadata == 7 then
  54.     turtle.digDown()
  55.     fSscan()
  56.     turtle.placeDown()
  57.   elseif tMeta.metadata == nil then
  58.     turtle.placeDown()
  59.   end
  60.   fSubforward()
  61. end
  62. function fDnS()
  63.   for i = 2, 15 do
  64.     turtle.select(i)
  65.     repeat
  66.       bFull = turtle.drop()
  67.       if bFull == false and turtle.getItemCount() ~= 0 then
  68.         print('Get your Wheat you lazy scum!')
  69.         sleep(1)
  70.       else
  71.         break
  72.       end
  73.     until bFull == true
  74.   end
  75.   turtle.select(1)
  76.   turtle.turnRight()
  77.   turtle.forward()
  78. end
  79. function fFuelcheck(l, w)
  80.   if w/2 == math.ceil(w/2) then
  81.     nFuelR = (l*(w+1))+w+l+1
  82.   else
  83.     nFuelR = (l*(w+1))+w+1
  84.   end
  85.     nCurFuel = turtle.getFuelLevel()
  86.   if nCurFuel < nFuelR then
  87.     turtle.select(16)
  88.     turtle.suck() --gives chest that nice succ
  89.     repeat
  90.       bFuelup = turtle.refuel(1)
  91.       if bFuelup == false then
  92.         sleep(1)
  93.       end
  94.     until nCurFuel <= nFuelR
  95.     turtle.drop()
  96.     turtle.select(1)
  97.   end  
  98. end
  99. function fMkui()
  100.   term.setBackgroundColor(colors.lightBlue)
  101.   term.clear()
  102.   term.setTextColor(colors.white)
  103.   term.setCursorPos(1, 1)
  104.   print('            _            _')
  105.   print('        .-./*) |------| (*\\.-.')
  106.   print('      _/___\\/     ||     \\/___\\_')
  107.   print('        U U       ||ARTLE  U U')
  108. end
  109. function fFarm()
  110.   fMkui()
  111.   term.setCursorPos(1, 6)
  112.   fFuelcheck(tArgs[1], tArgs[2])
  113.   for i = 1, y+1 do
  114.     for j = 1, x do
  115.       fSforward()
  116.     end
  117.     if i/2 ~= math.ceil(i/2) and i ~= y+1 then
  118.       for i = 1, 2 do
  119.         turtle.turnRight()
  120.         fSubforward()
  121.       end
  122.     elseif i ~= y+1 then
  123.       for i = 1, 2 do
  124.         turtle.turnLeft()
  125.         fSubforward()
  126.       end
  127.     else
  128.       if (i-1)/2 == math.ceil((i-1)/2) then
  129.         turtle.turnLeft()
  130.         for j = 1, y do
  131.           fSubforward()
  132.         end
  133.         turtle.turnLeft()
  134.         for j = 1, x+1 do
  135.           fSubforward()
  136.         end
  137.         turtle.turnRight()
  138.         fDnS()
  139.       else
  140.         turtle.turnRight()
  141.         for j = 1, y do
  142.           fSubforward()
  143.         end
  144.         fDnS()
  145.       end
  146.     end
  147.   end
  148. end
  149. fFarm()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement