Advertisement
Guest User

miner

a guest
Sep 21st, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.17 KB | None | 0 0
  1. local length = 100
  2.  
  3. local fuelNeeded = (((length*3)*2)*3)+27)
  4.  
  5.  
  6. local function fillUp()
  7.     while (turtle.getFuelLevel() < fuelNeeded) do
  8.         turtle.select(1)
  9.         if (turtle.getItemCount(1) == 0) then
  10.             print("Please supply fuel in slot 1!")
  11.             return false
  12.         end
  13.         turtle.refuel(1)
  14.     end
  15.     return true
  16. end
  17.    
  18.  
  19. local function torchCheck()
  20.     if (((length / 3) * 2) > turtle.getItemCount(2)) then
  21.         print("Please feed me torches in slot 2!")
  22.         return false
  23.     end
  24.     return true
  25. end
  26.  
  27.  
  28. local function makeLight()
  29.     turtle.select(2)
  30.     turtle.turnLeft()
  31.     turtle.place() 
  32.     turtle.turnRight()
  33. end
  34.  
  35.  
  36. local function dig()
  37.     while (turtle.detect()) do
  38.         turtle.dig()
  39.         sleep(0.5)
  40.     end
  41. end
  42.  
  43.  
  44. local function makeTunnel()
  45.     local lengthComp = 0
  46.     local torchplace = 0
  47.    
  48.     while (i < length) do
  49.         dig()
  50.         turtle.up()
  51.         dig()
  52.         turtle.forward()
  53.         turtle.down()
  54.                
  55.         if lengthComp % 10 == 0 then
  56.             makeLight()
  57.         end
  58.        
  59.         lengthComp = lengthComp + 1
  60.     end
  61. end
  62.  
  63.  
  64. local function overARow()
  65.     local newRow = 0
  66.    
  67.     turtle.turnLeft()
  68.    
  69.     while (newRow < 3) do
  70.         dig()
  71.         turtle.down()
  72.         dig()
  73.         turtle.forward()
  74.         turtle.up()
  75.         newRow = newRow + 1
  76.     end
  77.    
  78.     turtle.turnRight()
  79. end
  80.  
  81.  
  82. local function backToStart()
  83.     local comeBack = 0
  84.    
  85.     turtle.turnRight()
  86.     turtle.turnRight()
  87.    
  88.     while (comeBack < length) do
  89.         turtle.forward()
  90.         comeBack = comeBack + 1
  91.     end
  92.    
  93.     turtle.turnRight()
  94.     turtle.turnRight()
  95. end
  96.    
  97.  
  98. local function checkInventory()
  99.     local inventory = 0
  100.     local slotsFull = 0
  101.    
  102.     while (inventory < 16) do
  103.         inventory = inventory + 1
  104.         slotStatus = turtle.getItemCount(inventory)
  105.         if (slotStatus > 0) then
  106.             slotsFull = slotsFull + 1
  107.         end
  108.     end
  109.    
  110.     if (slotsFull == 16) then
  111.         return false
  112.     end
  113.    
  114.     return true
  115. end
  116.  
  117.  
  118. local function returnHome()
  119.     local i = 0
  120.    
  121.     turtle.turnLeft()
  122.    
  123.     while (i < 3) do
  124.         turtle.forward()
  125.         i = i + 1
  126.     end
  127. end
  128.    
  129. if fillUp() and torchCheck() then
  130.     local rowsFromStart = 0
  131.    
  132.     while checkInventory()
  133.         makeTunnel()
  134.         backToStart()
  135.         overARow()
  136.         rowsFromStart = rowsFromStart + 1
  137.     end
  138.    
  139.     if (rowsFromStart > 1) then
  140.         while (returnToHome < rowsFromStart) do
  141.             returnHome()
  142.   end
  143.  end
  144. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement