Cwmwd24

StripMine2

Oct 23rd, 2015
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.50 KB | None | 0 0
  1. -- -------------------------------------------------------------------------- --
  2. -- Strip Miner 2 : JwLnF6ey
  3. --
  4. -- Better strip miner.
  5. --
  6. -- -------------------------------------------------------------------------- --
  7. --
  8. -- INVENTORY:
  9. -- [1][2][3][4]
  10. -- [5][6][7][8]
  11. -- [9][A][B][C]
  12. -- [D][E][F][0]
  13. --
  14. -- 1 : Fuel
  15. -- 2 : Torches
  16. -- 3 : Bridge material
  17. -- 4 :
  18. -- Rest should be empty.
  19. --
  20. -- -------------------------------------------------------------------------- --
  21.  
  22.  
  23. local function CheckFuel()
  24.   if turtle.getFuelLevel() < 64 and turtle.getItemCount( 1 ) > 1 then
  25.     turtle.select( 1 )
  26.     turtle.refuel( 1 )
  27.   end
  28.   return
  29. end
  30.  
  31. local function PlaceTorch()
  32.   if turtle.getItemCount( 2 ) > 1 then
  33.     turtle.select( 2 )
  34.     turtle.back()
  35.     turtle.placeUp()
  36.     turtle.forward()
  37.   end
  38.   return
  39. end
  40.  
  41. local function PlaceTorchBehind()
  42.   if turtle.getItemCount( 2 ) > 1 then
  43.     turtle.back()
  44.     turtle.up()
  45.     turtle.select( 2 )
  46.     turtle.placeDown()
  47.     turtle.forward()
  48.     turtle.down()
  49.   end
  50.   return
  51. end
  52.  
  53. local function DigForward()
  54.   -- Clear the bolck directly ahead, mov into it's space and then dig up.
  55.   -- If resulting 1x1x2 gap is in mid ar then place a filler block below
  56.   -- to bridg the gap.
  57.   --
  58.  
  59.   while turtle.detect() do
  60.     turtle.dig()
  61.     sleep( 0.5 ) -- Pause to let sand/gravel fall!
  62.   end
  63.   turtle.forward()
  64.   while turtle.detectUp() do
  65.     turtle.digUp()
  66.     sleep( 0.5 ) -- Pause to let sand/gravel fall!
  67.   end
  68.   turtle.select( 3 )
  69.   while not turtle.detectDown() do
  70.     turtle.placeDown()
  71.   end
  72.  
  73.   return
  74. end
  75.  
  76. local function DigBranch()
  77.   -- Dig a 16-block tunnel with a torch at the end.
  78.  
  79.   CheckFuel()
  80.   for step = 1, 16 do
  81.     DigForward()
  82.   end
  83.   PlaceTorch()
  84.   return
  85. end
  86.  
  87. local function DigStub( direction )
  88.   -- Turn to the left or right, dig a 3-block tunnel and then turn left or right again.
  89.  
  90.   if direction == "left" then
  91.     turtle.turnLeft()
  92.   else
  93.     turtle.turnRight()
  94.   end
  95.   DigForward()
  96.   DigForward()
  97.   DigForward()
  98.   if direction == "left" then
  99.     turtle.turnLeft()
  100.   else
  101.     turtle.turnRight()
  102.   end
  103.   return
  104. end
  105.  
  106. local function ClearChamberOne()
  107.   -- Clear out a 3x3x2 chamber directly ahead with a torch in the middle (square 2). Park
  108.   -- ourselves at the right hand wall (square 8).
  109.   --
  110.   -- ===========
  111.   -- =[4][3][9]=
  112.   -- =[5][2][8]=
  113.   -- =[6][1][7]=
  114.   -- ==== X ====
  115.   --
  116.  
  117.   CheckFuel()
  118.   DigForward()  -- [1]
  119.   DigForward()  -- [2]
  120.   DigForward()  -- [3]
  121.   PlaceTorchBehind()
  122.  
  123.   turtle.turnLeft()
  124.   DigForward()  -- [4]
  125.  
  126.   turtle.turnLeft()
  127.   DigForward()  -- [5]
  128.   DigForward()  -- [6]
  129.  
  130.   turtle.turnLeft()
  131.   turtle.forward()
  132.   DigForward()  -- [7]
  133.  
  134.   turtle.turnLeft()
  135.   DigForward()  -- [8]
  136.   DigForward()  -- [9]
  137.  
  138.   turtle.back()
  139.   turtle.turnRight()
  140.   DigForward()
  141.  
  142.   return
  143. end
  144.  
  145. local function ClearChamberTwo()
  146.   -- Clear out a 3x3x2 chamber directly ahead with a torch in the middle (square 2). Park
  147.   -- ourselves at the opposite wall (square 3).
  148.   --
  149.   -- ===========
  150.   -- =[4][3][9]=
  151.   -- =[5][2][8]=
  152.   -- =[6][1][7]=
  153.   -- ==== X ====
  154.   --
  155.  
  156.   CheckFuel()
  157.   DigForward()  -- [1]
  158.   DigForward()  -- [2]
  159.   DigForward()  -- [3]
  160.   PlaceTorchBehind()
  161.  
  162.   turtle.turnLeft()
  163.   DigForward()  -- [4]
  164.  
  165.   turtle.turnLeft()
  166.   DigForward()  -- [5]
  167.   DigForward()  -- [6]
  168.  
  169.   turtle.turnLeft()
  170.   turtle.forward()
  171.   DigForward()  -- [7]
  172.  
  173.   turtle.turnLeft()
  174.   DigForward()  -- [8]
  175.   DigForward()  -- [9]
  176.  
  177.   turtle.turnLeft()
  178.   turtle.forward()
  179.   turtle.turnRight()
  180.   DigForward()
  181.  
  182.   return
  183. end
  184.  
  185. local function LinkCorridor()
  186.   -- Go to the left wall of the chamber ahead (avoiding the torch)
  187.   -- and dig the link corridor between the two chambers. Return to
  188.   -- the first chamber just forward of our starting position.
  189.  
  190.   CheckFuel()
  191.   turtle.forward()
  192.   turtle.turnLeft()
  193.   turtle.forward()
  194.   turtle.turnRight()
  195.   turtle.forward()
  196.   turtle.turnLeft()
  197.  
  198.   for step = 1, 12 do
  199.     DigForward()
  200.   end
  201.  
  202.   turtle.up()
  203.   for step = 1, 14 do
  204.     turtle.back()
  205.   end
  206.   turtle.down()
  207.  
  208.   return
  209. end
  210.  
  211.  
  212. -- Start
  213. CheckFuel()
  214.  
  215. ClearChamberOne()
  216.  
  217. DigBranch()
  218. DigStub( "left" )
  219. DigBranch()
  220. DigStub( "right" )
  221. DigBranch()
  222. DigStub( "left" )
  223. DigBranch()
  224. DigStub( "right" )
  225. DigBranch()
  226. DigStub( "left" )
  227. DigBranch()
  228.  
  229. ClearChamberTwo()
  230.  
  231. DigBranch()
  232. DigStub( "left" )
  233. DigBranch()
  234. DigStub( "right" )
  235. DigBranch()
  236. DigStub( "left" )
  237. DigBranch()
  238. DigStub( "right" )
  239. DigBranch()
  240. DigStub( "left" )
  241. DigBranch()
  242.  
  243. LinkCorridor()
Advertisement
Add Comment
Please, Sign In to add comment