Cwackers

65WideNoFuel

Mar 6th, 2020
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local args = {...}
  2.  
  3. local stripLength = 33
  4. local count = 0
  5. local line = 0
  6.  
  7. if not #args == 1 then
  8.   print("Usage: smine <mines>")
  9.   return
  10. end
  11.  
  12. function strip()
  13.   count = 0
  14.   for i=1,stripLength do
  15.     count = count + 1
  16.     checkInv()
  17.     while not turtle.forward() do turtle.dig() end
  18.     while turtle.detectUp() do
  19.       turtle.digUp()
  20.       sleep(0.2)
  21.     end
  22.     while turtle.detectDown() do
  23.       turtle.digDown()
  24.       sleep(0.2)
  25.     end
  26.    
  27.     if line%8 == 0 then
  28.         if i%8 == 0 then
  29.          turtle.select(16)
  30.           while not turtle.forward() do turtle.dig() end
  31.           while turtle.detectDown() do
  32.          turtle.digDown()
  33.           sleep(0.2)
  34.           end
  35.       if not turtle.back() then
  36.         turtle.turnLeft()
  37.         turtle.turnLeft()
  38.         while not turtle.forward do turtle.dig() end
  39.         turtle.turnLeft()
  40.         turtle.turnLeft()
  41.       end
  42.       turtle.down()
  43.       if not turtle.detectDown() then
  44.          turtle.select(1)
  45.          turtle.placeDown()
  46.          turtle.select(16)
  47.       end
  48.       turtle.up()
  49.       turtle.placeDown()
  50.       turtle.select(1)
  51.     end
  52. end
  53.   end
  54.  
  55.   turtle.turnLeft()
  56.   turtle.turnLeft()
  57.  
  58.   for i=1,stripLength do
  59.     while not turtle.forward() do turtle.dig() end
  60.   end
  61. end
  62.  
  63. function checkFuel(count)
  64.   if turtle.getFuelLevel() <= count then
  65.     print("Error: Low fuel")
  66.     for i=1,14 do
  67.       turtle.select(i)
  68.       turtle.refuel()
  69.     end
  70.     turtle.select(1)
  71.     if turtle.getFuelLevel() <= count then
  72.         turtle.turnLeft()
  73.         turtle.turnLeft()
  74.         print("returning")
  75.         print(count)
  76.         for i=0,count do
  77.             turtle.forward()
  78.         end
  79.         emptyInv()
  80.         turtle.turnRight()
  81.     end
  82.   end
  83. end
  84.  
  85. function checkInv()
  86.   isFull = true
  87.  
  88.   for i=1,14 do
  89.     if turtle.getItemCount(i) == 0 then
  90.       isFull = false
  91.     end
  92.   end
  93.  
  94.   if isFull == true then
  95.     turtle.select(15)
  96.     while not turtle.placeDown() do turtle.digDown() end
  97.     for i=1,14 do
  98.       turtle.select(i)
  99.       turtle.dropDown()
  100.     end
  101.     turtle.select(15)
  102.     turtle.digDown()
  103.     sleep(0.2)
  104.     turtle.select(1)
  105.   end
  106. end
  107.  
  108. function emptyInv()
  109.     turtle.select(15)
  110.     while not turtle.placeDown() do turtle.digDown() end
  111.     for i=1,14 do
  112.         turtle.select(i)
  113.         turtle.dropDown()
  114.     end
  115.     turtle.select(15)
  116.     turtle.digDown()
  117.     sleep(0.2)
  118.     turtle.select(1)
  119. end
  120.  
  121. for x=1,args[1] do
  122.   turtle.turnLeft()
  123.   strip()
  124.   strip()
  125.   turtle.turnRight()
  126.  if line%8 == 0 then
  127.       turtle.select(16)
  128.       turtle.placeDown()
  129.       turtle.select(1)
  130.   end
  131.   while not turtle.forward() do turtle.dig() end
  132.     while turtle.detectUp() do
  133.       turtle.digUp()
  134.       sleep(0.2)
  135.     end
  136.     while turtle.detectDown() do
  137.       turtle.digDown()
  138.     end
  139.   line = line + 1
  140. print("Mined " .. x .. ", " .. args[1]-x .. " left to go.")
  141. end
  142. emptyInv()
Advertisement
Add Comment
Please, Sign In to add comment