zilvar2k11

ComputerCraft NZ Branch mining

Jul 9th, 2013
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.61 KB | None | 0 0
  1. -- NZ miner
  2.  
  3. local function dforward()
  4.   while turtle.detect() == true do
  5.     turtle.dig()
  6.         os.queueEvent("")
  7.         coroutine.yield()
  8.   end
  9.   turtle.forward()
  10. end
  11.  
  12. local function digUD()
  13.   while turtle.detectUp() == true do
  14.     turtle.digUp()
  15.         os.queueEvent("")
  16.         coroutine.yield()
  17.   end
  18.   turtle.digDown()
  19. end
  20.  
  21. local function digShort()
  22.   for toMove = 1,3 do
  23.     dforward()
  24.         digUD()
  25.   end
  26. end
  27.  
  28.  
  29. local function digTunnel()
  30.   for toMove = 1,6 do
  31.     dforward()
  32.         digUD()
  33.   end
  34. end
  35.  
  36. local function LorR( _x )
  37.   if (math.fmod(_x,2) == 0) then
  38.     turtle.turnRight()
  39.   else
  40.     turtle.turnLeft()
  41.   end
  42. end
  43.  
  44. local function makeCC()
  45.   turtle.turnLeft()
  46.   dforward()
  47.   digUD()
  48.   turtle.turnLeft()
  49.   turtle.turnLeft()
  50.   dforward()
  51.   dforward()
  52.   digUD()
  53.   turtle.turnLeft()
  54.   turtle.turnLeft()
  55.   turtle.forward()
  56.   turtle.turnRight()
  57. end
  58.  
  59. -- main, assumed to be starting just outside of the area you want to mine
  60. -- move forward for the starting leg
  61. digShort()
  62. -- setup the first crosscut
  63. dforward()
  64. digUD()
  65. turtle.back()
  66. -- face the correct direction
  67. turtle.turnRight()
  68.  
  69. -- for now, 7 iterations deep.  That's a good starting point.
  70. for x = 1,7 do
  71.   for y = 1,x do
  72.     -- already facing the correct direction.
  73.         digTunnel()
  74.         if (math.fmod(x,2) == 0) then
  75.           if (y == (x/2)) then
  76.             makeCC()
  77.           elseif (y == math.floor(x/2)+1) then
  78.             makeCC()
  79.           end
  80.         end
  81.   end
  82.   -- if X is even, turn right, forward, right.  Else turn left, forward, left
  83.   LorR(x)
  84.   digShort()
  85.   LorR(x)
  86. end
Advertisement
Add Comment
Please, Sign In to add comment