Advertisement
SythsGod

Strip Mining

Jul 9th, 2017
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.47 KB | None | 0 0
  1. -- 0.4
  2. -- strip mining
  3.  
  4. local switch = false
  5. local runsToDo = 5
  6. local fuelPerRun = 65
  7. local fuelNeeded = runsToDo * fuelPerRun
  8. local fuelLevel = turtle.getFuelLevel()
  9. local torchesPerRun = 6
  10. local torchesNeeded = torchesPerRun * runsToDo
  11. local torchesInInv = turtle.getItemCount(16)
  12. local isGravel = false
  13.  
  14. function digLine()
  15.     compareGravel()
  16.     turtle.dig()
  17.     turtle.forward()
  18.     turtle.digUp()
  19.     turtle.digDown()
  20. end
  21.  
  22. function compareGravel()
  23.     turtle.select(15)
  24.     isGravel = turtle.compare()
  25.  
  26.     print("Found gravel? " .. tostring(isGravel))
  27.  
  28.     if isGravel then dealWithGravel() end
  29. end
  30.  
  31. function dealWithGravel()
  32.     print("Dealing with gravel!")
  33.  
  34.     while isGravel do
  35.         turtle.dig()
  36.         compareGravel()
  37.     end
  38. end
  39.  
  40. function nextLineRight()
  41.     turtle.turnRight()
  42.     digLine()
  43.     digLine()
  44.     digLine()
  45.     turtle.turnRight()
  46. end
  47.  
  48. function nextLineLeft()
  49.     turtle.turnLeft()
  50.     digLine()
  51.     digLine()
  52.     digLine()
  53.     turtle.turnLeft()
  54. end
  55.  
  56. function fullRun()
  57.     for i = 0, 19, 1 do
  58.         digLine()
  59.  
  60.         if i == 3 or i == 11 or i == 18 then
  61.             turtle.select(16)
  62.             turtle.placeDown()
  63.             turtle.select(1)
  64.         end
  65.     end
  66. end
  67.  
  68. if fuelLevel < fuelNeeded then error("Not enough fuel!") end
  69. if torchesInInv < torchesNeeded then print("Will run out of torches!") end
  70.  
  71. for i = 1, runsToDo, 1 do
  72.     fullRun()
  73.  
  74.     if not switch then nextLineRight() else nextLineLeft() end
  75.     switch = not switch
  76.  
  77.     fullRun()
  78.  
  79.     if not switch then nextLineRight() else nextLineLeft() end
  80.     switch = not switch
  81. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement