Willibilly19

Quarry - Work in Progress

Jan 20th, 2013
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local tArgs = {...}
  2.  
  3. if #tArgs ~= 1 then
  4.   print("Usage: Quarry <size>")
  5. end
  6.  
  7. print("To Use: ")
  8. print("Place enderchest in slot 16.")
  9. print("Make sure the turtle has Fuel.")
  10.  
  11. local size = tArgs[1]
  12. local depth = 0
  13.  
  14.  
  15. --Functions
  16.  
  17. local function chest()        
  18.   if turtle.getItemCount(14) > 0 then
  19.     turtle.digUp()
  20.     turtle.select(16)
  21.     turtle.placeUp()
  22.     for i = 1,14 do
  23.       turtle.select(i)
  24.       turtle.dropUp()
  25.     end
  26.     turtle.select(16)
  27.     turtle.digUp()
  28.     turtle.select(1)
  29.   end
  30. end
  31.  
  32. local function forward()      
  33.   while not turtle.forward() do
  34.     turtle.dig()  
  35.     turtle.attack()
  36.     chest()
  37.   end
  38. end
  39.  
  40. local function down()
  41.   turtle.digDown()
  42.   turtle.down()
  43.   depth = depth + 1
  44. end
  45.  
  46. local function digLine()      
  47.   turtle.select(1)
  48.   for i = 1,size-1 do
  49.     forward()
  50.     while turtle.detectUp() do
  51.       turtle.digUp()
  52.     end
  53.     turtle.digDown()    
  54.   end
  55. end
  56.  
  57. local function left()            
  58.   turtle.turnLeft()
  59.   forward()
  60.   while turtle.detectUp() do
  61.     turtle.digUp()
  62.   end
  63.   turtle.digDown()
  64.   turtle.turnLeft()
  65. end
  66.  
  67. local function right()            
  68.   turtle.turnRight()
  69.   forward()
  70.   while turtle.detectUp() do
  71.     turtle.digUp()
  72.   end
  73.   turtle.digDown()
  74.   turtle.turnRight()
  75. end
  76.  
  77. local function spin()          
  78.   turtle.turnRight()
  79.   turtle.turnRight()
  80. end
  81.  
  82. local function back()          
  83.   spin()
  84.   for i = 1,size-1 do
  85.     forward()
  86.   end
  87.   turtle.turnRight()
  88.   for i = 1,size-1 do
  89.     forward()
  90.   end
  91.   turtle.turnRight()
  92. end
  93.  
  94. local function layer()            
  95.   for i = 1,size do
  96.     digLine()
  97.     if i%size == 0 then
  98.       if i%2 == 0 then
  99.         turtle.turnRight()
  100.         for i = 1,size-1 do
  101.           forward()
  102.         end
  103.         turtle.turnRight()
  104.       else
  105.         back()
  106.       end
  107.     elseif i%2 == 1 then
  108.       right()
  109.     else
  110.       left()
  111.     end
  112.   end
  113. end
  114.  
  115.  
  116.  
  117.  
  118. local function quarry()          
  119.   layer()
  120.   for i = 1,3 do
  121.     down()
  122.   end
  123. end
  124.  
  125. -- Main Code
  126.  
  127.  
  128. down()
  129. down()
  130. repeat
  131.   quarry()
  132. until turtle.detectDown() and not turtle.digDown()
  133.  
  134. repeat
  135.   turtle.up()
  136.   depth = depth - 1
  137. until depth == 0
Advertisement
Add Comment
Please, Sign In to add comment