Guest User

tunnel

a guest
Oct 14th, 2012
308
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.55 KB | None | 0 0
  1. function makeWall(x,count)
  2.   if x==1 then
  3.     --Right wall
  4.     turtle.turnRight()
  5.     if not turtle.detect() then
  6.       selectGlass()
  7.       turtle.place()
  8.     end
  9.     turtle.turnLeft()
  10.   elseif x==2 then
  11.     --Above
  12.     if count%6==0 then
  13.       turtle.digUp()
  14.       sleep(0.4)
  15.       while turtle.detectUp() do
  16.         turtle.digUp()
  17.         sleep(0.4)
  18.       end
  19.       selectGlow()
  20.       turtle.placeUp()
  21.     end
  22.     if not turtle.detectUp() then
  23.       selectGlass()
  24.       turtle.placeUp()
  25.     end
  26.   elseif x==3 then
  27.     --Left wall
  28.     turtle.turnLeft()
  29.     if not turtle.detect() then
  30.       selectGlass()
  31.       turtle.place()
  32.     end
  33.     turtle.turnRight()
  34.   elseif x==4 then
  35.     --Bottom
  36.     if not turtle.detectDown() then
  37.       selectGlass()
  38.       turtle.placeDown()
  39.     end
  40.   end
  41.  
  42. end
  43.  
  44. function selectGlass()
  45.    local x = 0
  46.    for i = 2,12 do
  47.     turtle.select(16)
  48.     if turtle.compareTo(i) then
  49.       if turtle.getItemCount(i)>16 then
  50.         turtle.select(i)
  51.         x = 1
  52.         return true
  53.       end
  54.     end
  55.    end      
  56.    if x == 0 then
  57.      return false
  58.    end
  59. end
  60.  
  61. function renewGlass()
  62.   while not selectGlass() do
  63.     selectChest()
  64.     turtle.placeDown()
  65.     turtle.suckDown()
  66.     turtle.suckDown()
  67.     if turtle.getItemSpace(11)<64 then
  68.       selectGlow()
  69.       turtle.dropDown()
  70.     end
  71.     turtle.dropDown()
  72.     collectChest()
  73.   end
  74. end
  75.  
  76. function selectGlow()
  77.   local x = 0
  78.   for i = 2,12 do
  79.     turtle.select(15)
  80.     if turtle.compareTo(i) then
  81.       if turtle.getItemCount(i)>16 then
  82.         turtle.select(i)
  83.         x = 1
  84.         return true
  85.       end
  86.     end
  87.   end
  88.   if x == 0 then
  89.     return false
  90.   end
  91. end
  92.  
  93. function renewGlow()
  94.   while not selectGlow() do
  95.     selectChest()
  96.     turtle.placeDown()
  97.     turtle.suckDown()
  98.     turtle.suckDown()
  99.     if turtle.getItemSpace(11)<64 then
  100.       selectGlass()
  101.       turtle.dropDown()
  102.     end
  103.     turtle.dropDown()
  104.     collectChest()
  105.   end
  106. end
  107.  
  108. function selectChest()
  109.   turtle.select(1)
  110. end
  111.  
  112. function selectChest1()
  113.   for i=1,12 do
  114.     turtle.select(14)
  115.     if turtle.compareTo(i) then
  116.       turtle.select(i)
  117.     end
  118.   end
  119. end
  120.  
  121. function collectChest()
  122.   turtle.select(1)
  123.   turtle.digDown()  
  124. end
  125.  
  126. function forward()
  127.   renewGlass()
  128.   renewGlow()
  129.   if turtle.getItemCount(12)>=1 then
  130.     turtle.select(12)
  131.     turtle.drop()
  132.   end
  133.   makeWall(1,count)
  134.   makeWall(2,count)
  135.   turtle.dig()
  136.   turtle.down()
  137.   makeWall(1,count)
  138.   turtle.dig()
  139.   turtle.down()
  140.   makeWall(1,count)
  141.   makeWall(4,count)
  142.   turtle.dig()
  143.   sleep(0.6)
  144.   while turtle.detect() do
  145.     turtle.dig()
  146.     sleep(0.4)
  147.   end
  148.   turtle.turnLeft()
  149.   turtle.forward()
  150.   turtle.turnRight()
  151.   makeWall(4,count)
  152.   turtle.dig()
  153.   sleep(0.4)
  154.   while turtle.detect() do
  155.     turtle.dig()
  156.     sleep(0.4)
  157.   end
  158.   turtle.up()
  159.   turtle.dig()
  160.   turtle.up()
  161.   makeWall(2,count)
  162.   turtle.dig()
  163.   turtle.turnLeft()
  164.   turtle.forward()
  165.   turtle.turnRight()
  166.   makeWall(2,count)
  167.   makeWall(3,count)
  168.   turtle.dig()
  169.   turtle.down()
  170.   makeWall(3,count)
  171.   turtle.dig()
  172.   turtle.down()
  173.   makeWall(3,count)
  174.   makeWall(4,count)
  175.   turtle.dig()
  176.   sleep(0.4)
  177.   while turtle.detect() do
  178.     turtle.dig()
  179.     sleep(0.4)
  180.   end
  181.   turtle.turnRight()
  182.   turtle.forward()
  183.   turtle.forward()
  184.   turtle.turnLeft()
  185.   turtle.up()
  186.   turtle.up()
  187.   turtle.forward()
  188.   count=count+1
  189.   return true
  190. end
  191.  
  192. count = 0
  193. term.clear()
  194. term.setCursorPos(1,1)
  195. print("Enter how many blocks forward you would like to mine: ")
  196. blocks = io.read()
  197. for i=1,blocks do
  198.   forward()
  199. end
Advertisement
Add Comment
Please, Sign In to add comment