WotNoName

Advanced Tunnel by Henness

Aug 11th, 2012
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 23.03 KB | None | 0 0
  1. -- Advanced Tunnel by Henness
  2. -- Version 1.3.1 5/5/2012
  3.  
  4. -- Config
  5. Version = "v1.3.1"
  6. HeightQuestion = true
  7. WidthQuestion = true
  8. LengthQuestion = true
  9. TorchesQuestion = true
  10. Intro = true
  11.  
  12. -- Functions
  13. function version() -- Version function
  14.     return Version
  15. end
  16.  
  17. function clearscreen() -- Clearscreen function
  18.     term.clear()
  19.     regwrite( "Advanced Tunnel", 12, 1 )
  20.     regwrite( version(), 2, 12 )
  21.     regwrite( "Designed by Henness", 17, 12 )
  22.     term.setCursorPos( 1, 3 )
  23. end
  24.  
  25. function regwrite(string, columnVar, rowVar) -- Write a string to the cords
  26.     term.setCursorPos( columnVar, rowVar )
  27.     write (string)
  28. end
  29.  
  30. function arcwrite(number, columnVar, rowVar) -- Write a number "right to left" to the cords
  31.     digits = math.ceil(math.log10(number))
  32.     if 10^digits == number then
  33.         digits = digits + 1
  34.     end
  35.     term.setCursorPos( columnVar, rowVar )
  36.     while digits > 1 do
  37.         digits = digits - 1
  38.         columnVar = columnVar - 1
  39.         term.setCursorPos( columnVar, rowVar )
  40.     end
  41.     write (number)
  42. end
  43.  
  44. function createtable() -- Make a table function
  45. clearscreen()
  46. print ( [[
  47.  +--------------------------------+
  48.  |Blocks Mined:                 0 |
  49.  |Torches Placed:               0 |
  50.  +--------------------------------+
  51.  |             Status             |
  52.  |[                              ]|
  53.  |                0%              |
  54.  +--------------------------------+
  55. ]] )
  56. placedValue = 0
  57. minedValue = 0
  58. end
  59.  
  60. function updatetable() -- Update the table
  61.     -- Update Blocks Mined
  62.     minedValue = minedValue + 1
  63.     arcwrite(minedValue, 33, 4)
  64.    
  65.     -- Update Percentage
  66.     if length > 0 then
  67.         area = (height * width * length)
  68.     else
  69.         area = minedValue
  70.     end
  71.     percentage = math.ceil((minedValue / area) * 100)
  72.     arcwrite(percentage, 19, 9)
  73.    
  74.     -- Update Percentage Bar
  75.     percentageBar = math.floor(percentage * 0.3)
  76.     columnVar = 4
  77.     while percentageBar > 0 do
  78.         regwrite( "=", columnVar, 8 )
  79.         percentageBar = percentageBar - 1
  80.         columnVar = columnVar + 1
  81.     end
  82. end
  83.  
  84. function placetorch() -- Place a torch
  85.     if torches == true then
  86.         if lengthSpacingVar == 0 and ( spaceFromWallVar == 0 or widthSpacingVar == 0 ) then
  87.             turtle.placeDown()
  88.             if turtle.getItemCount(1) == 0 then
  89.                 noTorches = true
  90.             end
  91.             spaceFromWallVar = -1
  92.             widthSpacingVar = widthSpacing
  93.             -- Update Torches Placed
  94.             placedValue = placedValue + 1
  95.             arcwrite(placedValue, 33, 5)
  96.         else
  97.             spaceFromWallVar = spaceFromWallVar - 1
  98.             widthSpacingVar = widthSpacingVar - 1
  99.         end
  100.     end
  101. end
  102.  
  103. function widthtest() -- Test width for numbers that = 4+10n
  104.     widthTestVar = width
  105.     while widthTestVar > 4 do
  106.         widthTestVar = widthTestVar - 10
  107.     end
  108.     if widthTestVar == 4 then
  109.         return true
  110.     end
  111. end
  112.  
  113. function setspacing() -- Calculate spacing of torches
  114.     if width < 6 then
  115.         if math.fmod( width, 2 ) == 0 then -- If even
  116.             if width == 2 then
  117.                 lengthSpacing = 9
  118.                 spaceFromWall = ( 1 + ( -1 )^placedValue ) / 2
  119.             else
  120.                 lengthSpacing = 7
  121.                 spaceFromWall = (( 1 + ( -1 )^placedValue ) / 2 ) + 1
  122.             end
  123.         else -- If odd
  124.             spaceFromWall = math.floor( width / 2 )
  125.             if width == 5 then
  126.                 lengthSpacing = 6
  127.             elseif width == 3 then
  128.                 lengthSpacing = 8
  129.             else
  130.                 lengthSpacing = 10
  131.             end
  132.         end
  133.         widthSpacing = -1
  134.     else
  135.         if math.fmod( width, 2 ) == 0 then -- If even
  136.             widthSpacing = 4
  137.             lengthSpacing = 4
  138.             if widthtest() == true or width == 6 then
  139.                 spaceFromWall = 0          
  140.             else
  141.                 spaceFromWallVar = width
  142.                 while spaceFromWallVar > 7 do
  143.                     spaceFromWallVar = spaceFromWallVar - ( widthSpacing + 1 )
  144.                 end
  145.                 spaceFromWall = ( spaceFromWallVar - 1 ) / 2
  146.             end
  147.         else -- If odd
  148.             widthSpacing = 5
  149.             lengthSpacing = 4
  150.             if width == 7 then
  151.                 spaceFromWall = 0
  152.             else
  153.                 spaceFromWallVar = width
  154.                 while spaceFromWallVar > 7 do
  155.                     spaceFromWallVar = spaceFromWallVar - ( widthSpacing + 1 )
  156.                 end
  157.                 spaceFromWall = ( spaceFromWallVar - 1 ) / 2
  158.             end
  159.         end
  160.     end
  161.     spaceFromWallVar = spaceFromWall
  162.     widthSpacingVar = widthSpacing
  163.     lengthSpacingVar = lengthSpacing
  164. end
  165.  
  166. function digdown() -- Dig down and update the table
  167.     if turtle.detectDown() then
  168.         turtle.digDown()
  169.     end
  170.     updatetable()
  171. end
  172.  
  173. function digup() -- Dig up and update the table
  174.     while turtle.detectUp() == true do
  175.         turtle.digUp()
  176.         sleep(0.4)
  177.     end
  178.     updatetable()
  179. end
  180.  
  181. function digforward() -- Dig forward and update the table
  182.     while turtle.detect() == true do
  183.         turtle.dig()
  184.         sleep(0.4)
  185.     end
  186.     moveforward()
  187.     updatetable()
  188. end
  189.  
  190. function moveforward() -- Move forward
  191.     repeat
  192.         if turtle.forward() == true then
  193.             moved = true
  194.         else
  195.             moved = false
  196.         end
  197.     until moved == true
  198. end
  199.  
  200. function largetunnel() -- Mine a tunnel larger then one wide
  201.     widthvar = width - 1
  202.     while widthvar > 0 do
  203.         if tunnelheight == 1 then
  204.             digdown()
  205.             placetorch()
  206.             moveforward()
  207.         end
  208.         if tunnelheight == 2 then
  209.             digdown()
  210.             placetorch()
  211.             digforward()
  212.         end
  213.         if tunnelheight == 3 then
  214.             digup()
  215.             digdown()
  216.             placetorch()
  217.             digforward()
  218.         end
  219.         if tunnelheight > 3 then
  220.             digup()
  221.             digdown()
  222.             digforward()
  223.         end
  224.         widthvar = widthvar - 1
  225.     end
  226.     if tunnelheight == 1 then
  227.         digdown()
  228.         tunnelheight = tunnelheight - 1
  229.     elseif tunnelheight == 2 then
  230.         digdown()
  231.         tunnelheight = tunnelheight - 2
  232.     elseif tunnelheight == 3 then
  233.         digup()
  234.         digdown()
  235.         tunnelheight = tunnelheight - 3
  236.     else
  237.         digup()
  238.         digdown()
  239.         tunnelheight = tunnelheight - 3
  240.         if tunnelheight == 1 then
  241.             turtle.down()
  242.         end
  243.         if tunnelheight == 2 then
  244.             turtle.down()
  245.             digdown()
  246.             turtle.down()
  247.         end
  248.         if tunnelheight >= 3 then
  249.             turtle.down()
  250.             digdown()
  251.             turtle.down()
  252.             digdown()
  253.             turtle.down()
  254.         end
  255.     end
  256. end
  257.  
  258. function smalltunnel() -- Mine a one wide tunnel
  259.     if tunnelheight == 2 then
  260.         digdown()
  261.     end
  262.     if tunnelheight == 3 then
  263.         digup()
  264.         digdown()
  265.     end
  266.     if tunnelheight > 3 then
  267.         digup()
  268.         digdown()
  269.         turtle.down()
  270.         tunnelheight = tunnelheight - 3
  271.         while tunnelheight > 1 do
  272.             digdown()
  273.             turtle.down()
  274.             tunnelheight = tunnelheight - 1
  275.         end
  276.         digdown()
  277.     end
  278.     placetorch()
  279. end
  280.  
  281. -- Intro
  282. if Intro == true then
  283. term.clear()
  284. regwrite( [[
  285.                                    
  286.                                    
  287.                                    
  288.                                    
  289.                                    
  290.                                    
  291.                                   d
  292.                                  d8
  293. ]] , 1, 3 )
  294. sleep(0.001)
  295. regwrite ( [[
  296.                                    
  297.                                    
  298.                                   d
  299.                                  d8
  300.                                 d88
  301.                                d88P
  302.                               d8888
  303.                              d88P  
  304. ]] , 1, 3 )
  305. sleep(0.001)
  306. regwrite( [[
  307.                                 d88
  308.                                d888
  309.                               d88P8
  310.                              d88P 8
  311.                             d88P  8
  312.                            d88P   8
  313.                           d88888888
  314.                          d88P     8
  315. ]] , 1, 3 )
  316. sleep(0.001)
  317. regwrite( [[
  318.                             d8888  
  319.                            d88888  
  320.                           d88P888  
  321.                          d88P 888  
  322.                         d88P  888 d
  323.                        d88P   888 8
  324.                       d8888888888 Y
  325.                      d88P     888  
  326. ]] , 1, 3 )
  327. sleep(0.001)
  328. regwrite( [[
  329.                         d8888      
  330.                        d88888      
  331.                       d88P888      
  332.                      d88P 888  .d88
  333.                     d88P  888 d88"
  334.                   d88P   888 888  
  335.                  d8888888888 Y88b
  336.                 d88P     888  "Y88
  337. ]] , 1, 3 )
  338. sleep(0.001)
  339. regwrite( [[
  340.                     d8888      888
  341.                    d88888      888
  342.                   d88P888      888
  343.                  d88P 888  .d88888
  344.                 d88P  888 d88" 888
  345.               d88P   888 888  888
  346.              d8888888888 Y88b 888
  347.             d88P     888  "Y88888
  348. ]] , 1, 3 )
  349. sleep(0.001)
  350. regwrite( [[
  351.                 d8888      888    
  352.                d88888      888    
  353.               d88P888      888    
  354.              d88P 888  .d88888 888
  355.             d88P  888 d88" 888 888
  356.           d88P   888 888  888 Y88
  357.          d8888888888 Y88b 888  Y8b
  358.         d88P     888  "Y88888   Y8
  359. ]] , 1, 3 )
  360. sleep(0.001)
  361. regwrite( [[
  362.             d8888      888        
  363.            d88888      888        
  364.           d88P888      888        
  365.          d88P 888  .d88888 888  888
  366.         d88P  888 d88" 888 888  888
  367.       d88P   888 888  888 Y88  88P
  368.      d8888888888 Y88b 888  Y8bd8P
  369.     d88P     888  "Y88888   Y88P  
  370. ]] , 1, 3 )
  371. sleep(0.001)
  372. regwrite( [[
  373.         d8888      888            
  374.        d88888      888            
  375.       d88P888      888            
  376.      d88P 888  .d88888 888  888  88
  377.     d88P  888 d88" 888 888  888    
  378.   d88P   888 888  888 Y88  88P .d8
  379.  d8888888888 Y88b 888  Y8bd8P  888
  380. d88P     888  "Y88888   Y88P   "Y8
  381. ]] , 1, 3 )
  382. sleep(0.001)
  383. regwrite( [[
  384.    d8888      888                
  385.   d88888      888                
  386.  d88P888      888                
  387. d88P 888  .d88888 888  888  8888b.
  388. d88P  888 d88" 888 888  888     "88
  389. 88P   888 888  888 Y88  88P .d88888
  390. 888888888 Y88b 888  Y8bd8P  888  88
  391. P     888  "Y88888   Y88P   "Y88888
  392. ]] , 1, 3 )
  393. sleep(0.001)
  394. regwrite( [[
  395. d8888      888                    
  396. 88888      888                    
  397. 8P888      888                    
  398. P 888  .d88888 888  888  8888b.  88
  399.  888 d88" 888 888  888     "88b 88
  400.  888 888  888 Y88  88P .d888888 88
  401. 88888 Y88b 888  Y8bd8P  888  888 88
  402.  888  "Y88888   Y88P   "Y888888 88
  403. ]] , 1, 3 )
  404. sleep(0.001)
  405. regwrite( [[
  406. 8      888                        
  407. 8      888                        
  408. 8      888                        
  409. 8  .d88888 888  888  8888b.  88888b
  410. 8 d88" 888 888  888     "88b 888 "8
  411. 8 888  888 Y88  88P .d888888 888  8
  412. 8 Y88b 888  Y8bd8P  888  888 888  8
  413. 8  "Y88888   Y88P   "Y888888 888  8
  414. ]] , 1, 3 )
  415. sleep(0.001)
  416. regwrite( [[
  417.    888                            
  418.    888                            
  419.    888                            
  420. d88888 888  888  8888b.  88888b.  
  421. 8" 888 888  888     "88b 888 "88b d
  422. 8  888 Y88  88P .d888888 888  888 8
  423. 8b 888  Y8bd8P  888  888 888  888 Y
  424. Y88888   Y88P   "Y888888 888  888  
  425. ]] , 1, 3 )
  426. sleep(0.001)
  427. regwrite( [[
  428. 88                                
  429. 88                                
  430. 88                                
  431. 88 888  888  8888b.  88888b.   .d88
  432. 88 888  888     "88b 888 "88b d88P"
  433. 88 Y88  88P .d888888 888  888 888  
  434. 88  Y8bd8P  888  888 888  888 Y88b.
  435. 88   Y88P   "Y888888 888  888  "Y88
  436. ]] , 1, 3 )
  437. sleep(0.001)
  438. regwrite( [[
  439.                                  
  440.                                  
  441.                                  
  442. 88  888  8888b.  88888b.   .d8888b
  443. 88  888     "88b 888 "88b d88P"   d
  444. 88  88P .d888888 888  888 888     8
  445. Y8bd8P  888  888 888  888 Y88b.   Y
  446.  Y88P   "Y888888 888  888  "Y8888P
  447. ]] , 1, 3 )
  448. sleep(0.001)
  449. regwrite( [[
  450.                                    
  451.                                    
  452.                                    
  453. 888  8888b.  88888b.   .d8888b .d88
  454. 888     "88b 888 "88b d88P"   d8P  
  455. 88P .d888888 888  888 888     88888
  456. 8P  888  888 888  888 Y88b.   Y8b.
  457. P   "Y888888 888  888  "Y8888P "Y88
  458. ]] , 1, 3 )
  459. sleep(0.001)
  460. regwrite( [[
  461.                                    
  462.                                    
  463.                                    
  464. 8888b.  88888b.   .d8888b .d88b.  
  465.    "88b 888 "88b d88P"   d8P  Y8b d
  466. d888888 888  888 888     88888888 8
  467. 88  888 888  888 Y88b.   Y8b.     Y
  468. Y888888 888  888  "Y8888P "Y8888  
  469. ]] , 1, 3 )
  470. sleep(0.001)
  471. regwrite( [[
  472.                                  
  473.                                  
  474.                                  
  475. b.  88888b.   .d8888b .d88b.   .d88
  476. 88b 888 "88b d88P"   d8P  Y8b d88"
  477. 888 888  888 888     88888888 888  
  478. 888 888  888 Y88b.   Y8b.     Y88b
  479. 888 888  888  "Y8888P "Y8888   "Y88
  480. ]] , 1, 3 )
  481. sleep(0.001)
  482. regwrite( [[
  483.                               888
  484.                               888
  485.                               888
  486. 88888b.   .d8888b .d88b.   .d88888
  487. 888 "88b d88P"   d8P  Y8b d88" 888
  488. 888  888 888     88888888 888  888
  489. 888  888 Y88b.   Y8b.     Y88b 888
  490. 888  888  "Y8888P "Y8888   "Y88888
  491. ]] , 1, 3 )
  492. sleep(0.001)
  493. regwrite( [[
  494.                           888    
  495.                           888    
  496.                           888    
  497. 8b.   .d8888b .d88b.   .d88888    
  498. "88b d88P"   d8P  Y8b d88" 888    
  499.  888 888     88888888 888  888    
  500.  888 Y88b.   Y8b.     Y88b 888    
  501.  888  "Y8888P "Y8888   "Y88888    
  502. ]] , 1, 3 )
  503. sleep(0.001)
  504. regwrite( [[
  505.                       888      888
  506.                       888        
  507.                       888        
  508.  .d8888b .d88b.   .d88888        
  509. d88P"   d8P  Y8b d88" 888        
  510. 888     88888888 888  888        
  511. Y88b.   Y8b.     Y88b 888        
  512.  "Y8888P "Y8888   "Y88888        
  513. ]] , 1, 3 )
  514. sleep(0.001)
  515. regwrite( [[
  516.                    888      8888888
  517.                    888          888
  518.                    888          888
  519. 8888b .d88b.   .d88888          888
  520. P"   d8P  Y8b d88" 888          888
  521.      88888888 888  888          888
  522. b.   Y8b.     Y88b 888          888
  523. 8888P "Y8888   "Y88888          888
  524. ]] , 1, 3 )
  525. sleep(0.001)
  526. regwrite( [[
  527.                888      88888888888
  528.                888          888    
  529.                888          888    
  530. b .d88b.   .d88888          888  88
  531.  d8P  Y8b d88" 888          888  88
  532. 88888888 888  888          888  88
  533. Y8b.     Y88b 888          888  Y8
  534. P "Y8888   "Y88888          888   "
  535. ]] , 1, 3 )
  536. sleep(0.001)
  537. regwrite( [[
  538.            888      88888888888    
  539.            888          888        
  540.            888          888        
  541. 88b.   .d88888          888  888  8
  542.   Y8b d88" 888          888  888  8
  543. 88888 888  888          888  888  8
  544. .     Y88b 888          888  Y88b 8
  545. 8888   "Y88888          888   "Y888
  546. ]] , 1, 3 )
  547. sleep(0.001)
  548. regwrite( [[
  549.       888      88888888888        
  550.       888          888            
  551.       888          888            
  552.   .d88888          888  888  888 8
  553. b d88" 888          888  888  888 8
  554. 8 888  888          888  888  888 8
  555.   Y88b 888          888  Y88b 888 8
  556.    "Y88888          888   "Y88888 8
  557. ]] , 1, 3 )
  558. sleep(0.001)
  559. regwrite( [[
  560.    888      88888888888            
  561.    888          888                
  562.    888          888                
  563. d88888          888  888  888 88888
  564. 8" 888          888  888  888 888 "
  565. 8  888          888  888  888 888  
  566. 8b 888          888  Y88b 888 888  
  567. Y88888          888   "Y88888 888  
  568. ]] , 1, 3 )
  569. sleep(0.001)
  570. regwrite( [[
  571. 88      88888888888                
  572. 88          888                    
  573. 88          888                    
  574. 88          888  888  888 88888b.  
  575. 88          888  888  888 888 "88b
  576. 88          888  888  888 888  888
  577. 88          888  Y88b 888 888  888
  578. 88          888   "Y88888 888  888
  579. ]] , 1, 3 )
  580. sleep(0.001)
  581. regwrite( [[
  582.    88888888888                    
  583.        888                        
  584.        888                        
  585.        888  888  888 88888b.  8888
  586.        888  888  888 888 "88b 888
  587.         888  888  888 888  888 888
  588.         888  Y88b 888 888  888 888
  589.         888   "Y88888 888  888 888
  590. ]] , 1, 3 )
  591. sleep(0.001)
  592. regwrite( [[
  593. 88888888888                        
  594.    888                            
  595.    888                            
  596.    888  888  888 88888b.  88888b.
  597.    888  888  888 888 "88b 888 "88b
  598.    888  888  888 888  888 888  888
  599.    888  Y88b 888 888  888 888  888
  600.    888   "Y88888 888  888 888  888
  601. ]] , 1, 3 )
  602. sleep(0.001)
  603. regwrite( [[
  604. 8888888                            
  605. 888                                
  606. 888                                
  607. 888  888  888 88888b.  88888b.   .d
  608. 888  888  888 888 "88b 888 "88b d8P
  609. 888  888  888 888  888 888  888 888
  610. 888  Y88b 888 888  888 888  888 Y8b
  611. 888   "Y88888 888  888 888  888  "Y
  612. ]] , 1, 3 )
  613. sleep(0.001)
  614. regwrite( [[
  615. 888                                
  616.                                    
  617.                                    
  618.  888  888 88888b.  88888b.   .d88b.
  619.  888  888 888 "88b 888 "88b d8P  Y8
  620.  888  888 888  888 888  888 8888888
  621.  Y88b 888 888  888 888  888 Y8b.  
  622.   "Y88888 888  888 888  888  "Y8888
  623. ]] , 1, 3 )
  624. sleep(0.001)
  625. regwrite( [[
  626.                                  88
  627.                                  88
  628.                                  88
  629.   888 88888b.  88888b.   .d88b.  88
  630.   888 888 "88b 888 "88b d8P  Y8b 88
  631.   888 888  888 888  888 88888888 88
  632. b 888 888  888 888  888 Y8b.     88
  633. 88888 888  888 888  888  "Y8888  88
  634. ]] , 1, 3 )
  635. sleep(0.001)
  636. regwrite( [[
  637.                             888  
  638.                             888  
  639.                             888  
  640. 8 88888b.  88888b.   .d88b.  888  
  641. 8 888 "88b 888 "88b d8P  Y8b 888  
  642. 8 888  888 888  888 88888888 888  
  643. 8 888  888 888  888 Y8b.     888  
  644. 8 888  888 888  888  "Y8888  888  
  645. ]] , 1, 3 )
  646. sleep(0.001)
  647. regwrite( [[
  648.                          888      
  649.                          888      
  650.                          888      
  651. 888b.  88888b.   .d88b.  888      
  652. 8 "88b 888 "88b d8P  Y8b 888      
  653. 8  888 888  888 88888888 888      
  654. 8  888 888  888 Y8b.     888      
  655. 8  888 888  888  "Y8888  888      
  656. ]] , 1, 3 )
  657. sleep(0.001)
  658. regwrite( [[
  659.                     888          
  660.                     888          
  661.                     888          
  662. .  88888b.   .d88b.  888          
  663. 8b 888 "88b d8P  Y8b 888          
  664. 88 888  888 88888888 888          
  665. 88 888  888 Y8b.     888          
  666. 88 888  888  "Y8888  888          
  667. ]] , 1, 3 )
  668. sleep(0.001)
  669. regwrite( [[
  670.                 888              
  671.                 888              
  672.                 888              
  673. 8888b.   .d88b.  888              
  674. 88 "88b d8P  Y8b 888              
  675. 88  888 88888888 888              
  676. 88  888 Y8b.     888              
  677. 88  888  "Y8888  888              
  678. ]] , 1, 3 )
  679. sleep(0.001)
  680. regwrite( [[
  681.             888                  
  682.             888                  
  683.             888                  
  684. b.   .d88b.  888                  
  685. 88b d8P  Y8b 888                  
  686. 888 88888888 888                  
  687. 888 Y8b.     888                  
  688. 888  "Y8888  888                  
  689. ]] , 1, 3 )
  690. sleep(0.001)
  691. regwrite( [[
  692.          888                      
  693.          888                      
  694.          888                      
  695.  .d88b.  888                      
  696. d8P  Y8b 888                      
  697. 88888888 888                      
  698. Y8b.     888                      
  699.  "Y8888  888                      
  700. ]] , 1, 3 )
  701. sleep(0.001)
  702. regwrite( [[
  703.     888                          
  704.     888                          
  705.     888                          
  706. 8b.  888                          
  707. Y8b 888                          
  708. 8888 888                          
  709.     888                          
  710. 888  888                          
  711. ]] , 1, 3 )
  712. sleep(0.001)
  713. regwrite( [[
  714. 888                              
  715. 888                              
  716. 888                              
  717. 888                              
  718. 888                              
  719. 888                              
  720. 888                              
  721. 888                              
  722. ]] , 1, 3 )
  723. term.clear()
  724. sleep(0.2)
  725. end
  726.  
  727. -- Questions
  728. clearscreen()
  729. while HeightQuestion == true do -- Height Question
  730.     print("Height of tunnel?")
  731.     height = tonumber(read())
  732.     clearscreen()
  733.     if height == nil then
  734.         print( "Please answer with a number." )
  735.     elseif height >= 2 then
  736.         HeightQuestion = false
  737.         startheight = height - 3
  738.     elseif height == 1 then
  739.         print( "The tunnel height must be larger than one." )
  740.     elseif height == 0 then
  741.         print( "The tunnel height can't be infinite." )
  742.     else
  743.         print( "The tunnel height must be positive." )
  744.     end
  745. end
  746.  
  747. clearscreen()
  748. while WidthQuestion == true do -- Width Question
  749.     print("Width of tunnel?")
  750.     width = tonumber(read())
  751.     clearscreen()
  752.     if width == nil then
  753.         print( "Please answer with a number." )
  754.     elseif width > 0 then
  755.         WidthQuestion = false
  756.     elseif width == 0 then
  757.         print( "The tunnel width can't be infinite." )
  758.     else
  759.         print( "The tunnel width must be positive." )
  760.     end
  761. end
  762.  
  763. clearscreen()
  764. while LengthQuestion == true do -- Length Question
  765.     print("Length of tunnel?")
  766.     length = tonumber(read())
  767.     clearscreen()
  768.     if length == nil then
  769.         print( "Please answer with a number." )
  770.     elseif length > 0 then
  771.         LengthQuestion = false
  772.         lengthVar = 0  
  773.     elseif length == 0 then
  774.         LengthQuestion = false
  775.         Infinitelength = true
  776.         TorchesQuestion = false
  777.         TorchSpacingQuestion = false
  778.         lengthVar = (-1)
  779.     else
  780.         print( "The tunnel length must be positive." )
  781.     end
  782. end
  783.  
  784. clearscreen()
  785. while TorchesQuestion == true do -- Torch Question
  786.     print("Place torches?")
  787.     light = string.lower(read())
  788.     clearscreen()
  789.     if light == ( 'yes' ) then
  790.         if turtle.getItemCount(1) == 0 then
  791.             print("Please place torches in the first inventory slot.")
  792.         else
  793.         torches = true
  794.         TorchesQuestion = false
  795.         noTorches = false
  796.         setspacing()
  797.         lengthSpacingVar = 0
  798.         end
  799.     elseif light == ( 'no' ) then
  800.         torches = false
  801.         TorchesQuestion = false
  802.     else
  803.         print("Please answer yes or no.")
  804.     end
  805. end
  806.  
  807. -- Create the gui
  808. createtable()
  809.  
  810. -- Mining Loop
  811. turtle.up()
  812. while startheight > 0 do
  813.     turtle.up()
  814.     startheight = startheight - 1
  815. end
  816. while lengthVar < length do
  817.     lengthVar = lengthVar + 1
  818.     digforward()
  819.     if width > 1 then
  820.         turtle.turnRight()
  821.     end
  822.  
  823.     -- Mine a one wide tunnel or a larger tunnel.
  824.     tunnelheight = height
  825.     if width > 1 then
  826.         while tunnelheight > 0 do
  827.             largetunnel()
  828.             turtle.turnRight()
  829.             turtle.turnRight()
  830.             if tunnelheight > 0 then
  831.                 largetunnel()
  832.                 if tunnelheight > 0 then
  833.                     turtle.turnRight()
  834.                     turtle.turnRight()
  835.                 end
  836.             else
  837.                 widthvar = width - 1
  838.                 while widthvar > 0 do
  839.                     moveforward()
  840.                     widthvar = widthvar - 1
  841.                 end
  842.             end
  843.         end
  844.     else
  845.         smalltunnel()
  846.     end
  847.     if torches == true then
  848.         if lengthSpacingVar == 0 then
  849.             spaceFromWallVar = spaceFromWall
  850.             widthSpacingVar = widthSpacing
  851.             lengthSpacingVar = lengthSpacing
  852.         else
  853.             spaceFromWallVar = spaceFromWall
  854.             widthSpacingVar = widthSpacing
  855.             lengthSpacingVar = lengthSpacingVar - 1
  856.         end
  857.     end
  858.     startheight = height - 3
  859.     while startheight > 0 do
  860.         turtle.up()
  861.         startheight = startheight - 1
  862.     end
  863.  
  864.     -- Infinite Length
  865.     if Infinitelength == true then
  866.         lengthVar = lengthVar - 1
  867.     end
  868.  
  869.     -- Stop or Continue
  870.     if lengthVar == length or noTorches == true then
  871.         if width > 1 then
  872.             turtle.turnLeft()
  873.         else
  874.             turtle.turnRight()
  875.             turtle.turnRight()
  876.         end
  877.         while lengthVar > 0 do
  878.             moveforward()
  879.             lengthVar = lengthVar - 1
  880.         end
  881.         while startheight < ( height - 3 ) do
  882.             turtle.down()
  883.             startheight = startheight + 1
  884.         end
  885.         turtle.turnLeft()
  886.         turtle.turnLeft()
  887.         lengthVar = length
  888.         term.setCursorPos( 1, 11 )
  889.         if noTorches == true then
  890.             print ("Out of Torches!")
  891.         else
  892.             print ("Tunnel Complete!")
  893.         end
  894.         term.setCursorPos( 1, 2 )
  895.     else
  896.         if width > 1 then
  897.             turtle.turnRight()
  898.         end
  899.     end
  900. end
Add Comment
Please, Sign In to add comment