Cwmwd24

StripMine

Jun 5th, 2015
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- -------------------------------------------------------------------------- --
  2. -- Strip Miner : BHGp2V48
  3. --
  4. -- Turtle script to dig out a strip mine. Starting from initial position a
  5. -- 1x2x8 tunnel is dug out with a torch either end, bridging gaps. At the end of
  6. -- each tunnel the turtle will dig out 3 to the left and then start the next
  7. -- 1x2x8 tunnel to the left again. This is repeated 'till we're out of fuel, torches
  8. -- or room.
  9. --
  10. -- -------------------------------------------------------------------------- --
  11. --
  12. -- INVENTORY:
  13. -- [1][2][3][4]
  14. -- [5][6][7][8]
  15. -- [9][A][B][C]
  16. -- [D][E][F][0]
  17. --
  18. -- 1 : Fuel
  19. -- 2 : Torches
  20. -- 3 : Bridge material
  21. -- 4 :
  22. -- Rest should be empty.
  23. --
  24. -- -------------------------------------------------------------------------- --
  25.  
  26. local function CheckFuel()
  27.   if turtle.getFuelLevel() < 64 and turtle.getItemCount( 1 ) > 1 then
  28.     turtle.select( 1 )
  29.     turtle.refuel( 1 )
  30.   end
  31.   return
  32. end
  33.  
  34. local function PlaceTorch()
  35.   if turtle.getItemCount( 2 ) > 1 then
  36.     turtle.select( 2 )
  37.     turtle.place()
  38.   end
  39.   return
  40. end
  41.  
  42. local function DigBranch()
  43.   for step = 1, 9 do
  44.     while turtle.detect() do
  45.       turtle.dig()
  46.     end
  47.     turtle.forward()
  48.     while turtle.detectUp() do
  49.       turtle.digUp()
  50.     end
  51.     while not turtle.detectDown() do
  52.       turtle.select( 3 )
  53.       turtle.placeDown()
  54.     end
  55.     CheckFuel()
  56.   end
  57.   return
  58. end
  59.  
  60. local function DigTurn()
  61.   while turtle.detect() do
  62.     turtle.dig()
  63.   end
  64.   turtle.forward()
  65.  
  66.   turtle.turnLeft()
  67.   turtle.turnLeft()
  68.   PlaceTorch()
  69.   turtle.turnLeft()
  70.   turtle.turnLeft()
  71.  
  72.   while turtle.detectUp() do
  73.     turtle.digUp()
  74.   end
  75.   while not turtle.detectDown() do
  76.     turtle.select( 3 )
  77.     turtle.placeDown()
  78.   end  
  79.   while turtle.detect() do
  80.     turtle.dig()
  81.   end
  82.   turtle.forward()
  83.  
  84.   while turtle.detectUp() do
  85.     turtle.digUp()
  86.   end
  87.   while not turtle.detectDown() do
  88.     turtle.select( 3 )
  89.     turtle.placeDown()
  90.   end  
  91.   while turtle.detect() do
  92.     turtle.dig()
  93.   end
  94.   turtle.forward()
  95.   while turtle.detectUp() do
  96.     turtle.digUp()
  97.   end
  98.   CheckFuel()
  99.   return
  100. end
  101.  
  102. -- Start
  103. CheckFuel()
  104. while turtle.getFuelLevel() > 16 and turtle.getItemCount( 1 ) > 1 and turtle.getItemCount( 2 ) > 1 do
  105.   DigBranch()
  106.   turtle.turnLeft()
  107.   DigTurn()
  108.   turtle.turnLeft()
  109.  
  110.   DigBranch()
  111.   turtle.turnRight()
  112.   DigTurn()
  113.   turtle.turnRight()
  114. end
Advertisement
Add Comment
Please, Sign In to add comment