Justinjah91

Computercraft Safebranch

Mar 9th, 2020 (edited)
13,932
1
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 20.16 KB | Gaming | 1 0
  1. --[[
  2. This program is designed to create a SAFE branch mine with 3x3 hallways, with multiple turtles working in tandem. The turtles will seal off any holes in the walls and will light the mine as they dig it, ensuring that no mobs get into your mine! They will also seal off any lava or water so your mine does not flood [see note 1]. Each turtle is responsible for either a branch or the main trunk of the mine. It is recommended to use at least 3 turtles (one for the main trunk and one for a branch on each side of the trunk), but fewer can be used with some manual repositioning. How it works:
  3.  
  4. * The turtle will mine out a 3x3 area. As it does so, it will compare the blocks in the walls with whatever is placed in its first slot. If that block does not match slot 1, it will be replaced with whatever is in slot 2. For example, I use this with stone in slot 1 and cobblestone in slot 2. This means that anything in the walls that ISN'T stone will be replaced with cobblestone. If you were to place cobblestone in slots 1 and 2, the walls would end up being solid cobblestone. As it mines out these slices, a turtle will place torches so that the tunnel remains safe from mob spawns. For optimum torch utilization, users are recommended to make the length of their tunnels a multiple of 10.
  5.  
  6. * Before beginning each 3x3 slice of a tunnel, the turtle will check to make sure it has enough materials to adequately complete that slice. If it does not, it will return to the beginning of the branch mine to resupply. If the turtle's inventory gets full, it will also return to this position to unload.
  7.  
  8. * When the turtles are finished with mining out the branches, they will return to the main trunk and position themselves for the next branch. The user will need to specify the direction that the turtle will need to go (either right or left) to reach the next tunnel position.
  9.  
  10. * Lastly, more than 1 turtle can be assigned to work on each side of the main trunk (each working on their own tunnels). The number of turtles needs to be specified by the user.
  11.  
  12. * For specifics of the setup, go to https://imgur.com/a/GJglvsW
  13.  
  14. *Calling sequence: Safebranch <type> <length> <direction> <# of turtles> <min light lvl>
  15.     * <type> can be "side" or "main"
  16.     * <length> is the length of the tunnel you want mined
  17.     * <direction> is the direction the turtle should go when finished (l or r). This argument may be omitted for "main" tunnels
  18.         * Note that this direction is from the turtle's perspective. A turtle on the left side of the branch mine should probably move                     
  19.           to the right when they finish their branch
  20.     * <# of turtles> is the number of turtles on this side of the main tunnel. This argument may be omitted for "main" tunnels
  21.         * Should be at least 1, but can be as many as you like
  22.     * <min light lvl> is the minimum light level that you want to allow in your mine. To block mob spawns:
  23.         * For MC versions lower than 1.18, this should be greater than or equal to 8
  24.         * For 1.18+, it should be greater than or equal to 1.
  25.      
  26. Inventory Layout:
  27. 1 - Stone
  28. 2 - Cobble
  29. 3 - Torches
  30. 16 - Fuel (Optional)
  31.  
  32. [Note 1] More recent versions of CC (for minecraft 1.13+) include the ability to waterlog turtles. While this may not cause an issue for small pockets of water, it WILL cause issues for larger pockets or aquifers. There is no way to combat this unless the devs add an option to disable waterlogging. For this reason, I recommend digging a small 1x1x1 hole in the floor at the start of each tunnel to stop any floods that do occur. I know it is annoying to have water sources in the tunnel (it drives me crazy), but in these versions of CC the turtles are incapable of directly removing water. All workarounds that I have considered involve silly things, like giving the turtles sponges and/or buckets, thus taking up valuable inventory space and reducing their effectiveness as mining turtles. For the time being, I suggest using some water proof light source in slot 3 (like lanterns or glowstone). These sorts of workarounds should NOT be necessary on 1.12 and earlier.
  33.  
  34. --]]
  35. function usage()  --Displays usage tips when invalid inputs are entered
  36.     usagetext = {
  37.     'Usage: Safebranch <type> <length>',
  38.     '       <direction> <# of turtles>',
  39.     '       <min light lvl>',
  40.     ' ',
  41.     ' ',
  42.     '<type> can be "side" or "main"',
  43.     ' ',
  44.     '<length> is the length of the tunnel',
  45.     '         you want mined',
  46.     ' ',
  47.     '<direction> is the direction the turtle',
  48.     '            should go when finished (l',
  49.     '            or r). This argument may be',
  50.     '            omitted for "main" tunnels',
  51.     ' ',
  52.     '<# of turtles> is the number of turtles',
  53.     '               on this side of the main',
  54.     '               tunnel. This argument',
  55.     '               may be omitted for',
  56.     '               "main" tunnels',
  57.     ' ',
  58.     '<min light lvl> is the minimum light',
  59.     '                level that can block',
  60.     '                mob spawns. This',
  61.     '                argument may be',
  62.     '                omitted for "main"',
  63.     '                tunnels. For MC',
  64.     '                versions lower than',
  65.     '                1.18, this shouldbe 8,',
  66.     '                for 1.18+,it is 1.',
  67.     ' ',
  68.     'The arguments may be omitted for a text','prompt. For more help, type "Safebranch','help"',''}
  69.     textutils.pagedTabulate(usagetext)
  70.     return
  71. end
  72.  
  73. function clc()    --Quick command to clear the terminal (I use matlab a lot, so clc is natural for me)
  74.     term.clear()
  75.     term.setCursorPos(1,1)
  76. end
  77.  
  78. function stuck()    --Displays "I'm stuck" messages
  79.     print('I think I might have gotten myself stuck...')
  80.     print('Terminate program or press enter after obstacle is cleared.')
  81.     read()
  82. end
  83.  
  84. function searchinv()    --Searches turtle's inventory for items like currently selected item, and reloads slot if they are found
  85.     local ini_slot = turtle.getSelectedSlot()
  86.     if turtle.getFuelLevel() == 'unlimited' then
  87.         endslot = 16
  88.     else
  89.         endslot = 15
  90.     end
  91.     for i = 4,endslot do
  92.         restocktorches()    --If turtle is at the reloading station, this makes sure the turtle has at least 32 torches
  93.         turtle.select(i)
  94.         if turtle.compareTo(ini_slot) then
  95.             turtle.transferTo(ini_slot)
  96.             if ini_slot == cobble then
  97.                 if turtle.getItemCount(ini_slot) > 22 then      --At most, a turtle will need 22 pieces of cobble for a slice of branch mine. This makes sure he has it
  98.                     turtle.select(ini_slot)
  99.                     return true
  100.                 end
  101.             else
  102.                 turtle.select(ini_slot)
  103.                 return true
  104.             end
  105.         end
  106.     end
  107.     turtle.select(ini_slot)
  108.     return false
  109. end
  110.  
  111. function addfuel()          --Checks if a turtle needs fuel, and refuels if it does.
  112.     if turtle.getFuelLevel() == 'unlimited' then
  113.     elseif turtle.getFuelLevel() == 0 then
  114.         local ini_slot = turtle.getSelectedSlot()
  115.         turtle.select(fuel)
  116.         if turtle.getItemCount() > 1 then
  117.             turtle.refuel(1)
  118.         elseif turtle.getItemCount() == 1 then
  119.             for i = 4,15 do
  120.                 turtle.select(i)
  121.                 if turtle.refuel(1) then
  122.                     break
  123.                 elseif i == 15 then
  124.                     turtle.select(fuel)
  125.                     print('I am out of fuel. Please load fuel into slot '..tostring(fuel))
  126.                     print('Press enter after fuel is loaded.')
  127.                     read()
  128.                     turtle.refuel(1)               
  129.                 end
  130.             end
  131.         else
  132.             print('Slot '..tostring(fuel)..' must contain a fuel item!')
  133.         end
  134.         turtle.select(ini_slot)
  135.     end
  136. end
  137.  
  138. function tup()      --Guarantees that a turtle will move up when told (gravel, sand, water, lava, and mob proof)
  139.     addfuel()
  140.     local attempt = 0
  141.     while turtle.up() == false do
  142.         turtle.digUp()
  143.         turtle.attackUp()
  144.         attempt = attempt + 1
  145.         if attempt >= 10 then
  146.             stuck()
  147.         end
  148.     end
  149. end
  150.  
  151. function tdn()      --Guarantees that a turtle will move down when told (gravel, sand, water, lava, and mob proof)
  152.     addfuel()
  153.     local attempt = 0
  154.     while turtle.down() == false do
  155.         turtle.digDown()
  156.         turtle.attackDown()
  157.         attempt = attempt + 1
  158.         if attempt >= 10 then
  159.             stuck()
  160.         end
  161.     end
  162. end
  163.  
  164. function tfd()      --Guarantees that a turtle will move forward when told (gravel, sand, water, lava, and mob proof)
  165.     addfuel()
  166.     local attempt = 0
  167.     while turtle.forward() == false do
  168.         turtle.dig()
  169.         turtle.attack()
  170.         attempt = attempt + 1
  171.         if attempt >= 10 then
  172.             stuck()
  173.         end
  174.     end
  175. end
  176.  
  177. function tbk()      --Guarantees that a turtle will move back when told (gravel, sand, water, lava, and mob proof)
  178.     addfuel()
  179.     if turtle.back() == false then
  180.         turtle.turnRight()
  181.         turtle.turnRight()
  182.         tfd()
  183.         turtle.turnRight()
  184.         turtle.turnRight()
  185.     end
  186. end
  187.  
  188. function cup()      --Compares the block above turtle to slot 1 and replaces it with slot 2 if it doesnt match
  189.     local ini_slot = turtle.getSelectedSlot()
  190.     turtle.select(stone)
  191.     if turtle.compareUp() == false then
  192.         turtle.select(cobble)
  193.         if turtle.compareUp() == false then
  194.             if turtle.getItemCount() <= 1 then
  195.                 if searchinv() == false then
  196.                     print('I need more of item '..tostring(cobble)..'.')
  197.                     print('Press enter after reloading...')
  198.                     read()
  199.                 end
  200.             end
  201.             local attempt = 0
  202.             while turtle.placeUp() == false do
  203.                 turtle.digUp()
  204.                 turtle.attackUp()
  205.                 attempt = attempt + 1
  206.                 if attempt >= 10 then
  207.                     stuck()
  208.                 end
  209.             end
  210.         end
  211.     end
  212.     turtle.select(ini_slot)
  213. end
  214.  
  215. function cdn()      --Compares the block below turtle to slot 1 and replaces it with slot 2 if it doesnt match
  216.     local ini_slot = turtle.getSelectedSlot()
  217.     turtle.select(stone)
  218.     if turtle.compareDown() == false then
  219.         turtle.select(cobble)
  220.         if turtle.compareDown() == false then
  221.             if turtle.getItemCount() <= 1 then
  222.                 if searchinv() == false then
  223.                     print('I need more of item '..tostring(cobble)..'.')
  224.                     print('Press enter after reloading...')
  225.                     read()
  226.                 end
  227.             end
  228.             local attempt = 0
  229.             while turtle.placeDown() == false do
  230.                 turtle.digDown()
  231.                 turtle.attackDown()
  232.                 attempt = attempt + 1
  233.                 if attempt >= 10 then
  234.                     stuck()
  235.                 end
  236.             end
  237.         end
  238.     end
  239.     turtle.select(ini_slot)
  240. end
  241.  
  242. function cfd()          --Compares the block in front of turtle to slot 1 and replaces it with slot 2 if it doesnt match
  243.     local ini_slot = turtle.getSelectedSlot()
  244.     turtle.select(stone)
  245.     if turtle.compare() == false then
  246.         turtle.select(cobble)
  247.         if turtle.compare() == false then
  248.             if turtle.getItemCount() <= 1 then
  249.                 if searchinv() == false then
  250.                     print('I need more of item '..tostring(cobble)..'.')
  251.                     print('Press enter after reloading...')
  252.                     read()
  253.                 end
  254.             end
  255.             local attempt = 0
  256.             while turtle.place() == false do
  257.                 turtle.dig()
  258.                 turtle.attack()
  259.                 attempt = attempt + 1
  260.                 if attempt >= 10 then
  261.                     stuck()
  262.                 end
  263.             end
  264.         end
  265.     end
  266.     turtle.select(ini_slot)
  267. end
  268.  
  269. function placetorch()       --Turns turtle around and places a torch
  270.     local ini_slot = turtle.getSelectedSlot()
  271.     turtle.turnLeft()
  272.     turtle.turnLeft()
  273.     local attempt = 0
  274.     turtle.select(torch)
  275.     if turtle.getItemCount() <= 1 then
  276.         print('I need more torches in slot '..tostring(turtle.getSelectedSlot())..'.')
  277.         print('Press enter after reloading...')
  278.         read()
  279.     end
  280.     tup()
  281.     tfd()
  282.     while turtle.placeDown() == false do
  283.         turtle.attackDown()
  284.         turtle.digDown()
  285.         attempt = attempt + 1
  286.         if attempt >= 10 then
  287.             stuck()
  288.         end
  289.     end
  290.     tbk()
  291.     tdn()
  292.     turtle.turnLeft()
  293.     turtle.turnLeft()
  294.     turtle.select(ini_slot)
  295. end
  296.  
  297. function checkstock(position)       --Checks to make sure turtle has sufficient supplies for this slice of mining. Position is fed to this function so the turtle can get back to its tunnel if it needs to go restock
  298.     position = position or 0
  299.     local ini_slot = turtle.getSelectedSlot()
  300.     if turtle.getItemCount(stone) < 1 then
  301.         turtle.select(stone)
  302.         if searchinv() == false then
  303.             print('I need more of item '..tostring(stone)..'.')
  304.             print('Press enter after reloading...')
  305.             read()
  306.         end
  307.     elseif turtle.getItemCount(cobble) < 22 then
  308.         turtle.select(cobble)
  309.         if searchinv() == false then
  310.             print('Restocking on item '..tostring(cobble)..'.')
  311.             restock(position)
  312.         end
  313.     elseif turtle.getItemCount(torch) < math.ceil(length/5) then
  314.         turtle.select(torch)
  315.         if searchinv() == false then
  316.             print('Restocking on torches.')
  317.             restock(position)
  318.         end
  319.     elseif turtle.getFuelLevel() ~= 'unlimited' and turtle.getItemCount(fuel) < 4 then
  320.         turtle.select(fuel)
  321.         if searchinv() == false then
  322.             print('Restocking on fuel.')
  323.             restock(position)
  324.         end
  325.     else
  326.         emptyslots = 0
  327.         for i = 1,16 do
  328.             if turtle.getItemCount(i) == 0 then
  329.                 emptyslots = emptyslots + 1
  330.             end
  331.         end
  332.         if emptyslots == 0 then
  333.             restock(position)
  334.         else
  335.             return true
  336.         end    
  337.     end
  338.     turtle.select(ini_slot)
  339. end
  340.  
  341. function restock(position)          --Sends the turtle back to the unload/reload chests to restock or deposit excess materials
  342.     turtle.turnLeft()
  343.     tfd()
  344.     turtle.turnLeft()
  345.     if tunneltype == 'side' then        --Determines if the turtle is a branch miner or trunk miner
  346.         for j = 1,position do
  347.             tfd()
  348.         end
  349.         if direction == "r" then    --Determines which way the chests are and orients to begin travel
  350.             turtle.turnRight()
  351.         else
  352.             while turtle.forward() == false do
  353.                 turtle.attack()
  354.             end
  355.             while turtle.forward() == false do
  356.                 turtle.attack()
  357.             end
  358.             turtle.turnLeft()
  359.             while turtle.forward() == false do
  360.                 turtle.attack()
  361.             end
  362.             while turtle.forward() == false do
  363.                 turtle.attack()
  364.             end
  365.         end
  366.     end
  367.     distfromchest = 0                       --This variable keeps up with how far the turtle travels to reach chest so it can get back to its tunnel
  368.     while turtle.detect() == false do
  369.         while turtle.forward() == false do
  370.             addfuel()
  371.             turtle.attack()
  372.         end
  373.         distfromchest = distfromchest + 1
  374.         if turtle.detect() then
  375.             local boolean, data = turtle.inspect() 
  376.             if string.find(string.lower(data.name),'turtle') then
  377.                 print('Detected another turtle. Waiting in line...')
  378.                 while turtle.detect() do
  379.                     sleep(7)
  380.                 end
  381.             elseif data.name == 'minecraft:chest' then
  382.             else
  383.                 print('Unknown Obstacle. Wating for clearance.')
  384.                 print('Press enter to continue...')
  385.                 read()
  386.             end
  387.         end
  388.     end
  389.     local ini_slot = turtle.getSelectedSlot()
  390.     if turtle.getItemCount(cobble) < 64 then        --Reloads cobble if needed
  391.         for i = 4,15 do
  392.             restocktorches()
  393.             turtle.select(i)
  394.             if turtle.compareTo(cobble) then
  395.                 turtle.transferTo(cobble)
  396.             end
  397.         end
  398.         if turtle.getItemCount(cobble) < 64 then
  399.             turtle.select(cobble)
  400.             turtle.suckDown()
  401.         end
  402.     end
  403.     if tunneltype == 'side' then
  404.         startslot = 4
  405.     else
  406.         startslot = 5
  407.     end
  408.     if turtle.getFuelLimit() == 'unlimited' then
  409.         endslot = 16
  410.     else
  411.         endslot = 15
  412.     end
  413.    
  414.     for i = startslot,endslot do
  415.         restocktorches()
  416.         turtle.select(i)
  417.         if turtle.compareTo(cobble) then            --Deposits excess materials
  418.             turtle.dropDown()
  419.         else
  420.             turtle.drop()
  421.         end
  422.     end
  423.     turtle.select(ini_slot)
  424.     tup()
  425.     turtle.turnLeft()
  426.     tfd()
  427.     tfd()
  428.     tdn()
  429.     turtle.turnLeft()
  430.     for z = distfromchest,1,-1 do               --Returns to branch or main trunk end
  431.         tfd()
  432.     end
  433.     if tunneltype == 'side' then
  434.         if direction == 'l' then
  435.             turtle.turnRight()
  436.         else
  437.             tfd()
  438.             tfd()
  439.             turtle.turnLeft()
  440.             tfd()
  441.             tfd()
  442.         end
  443.         for j = 1, position do
  444.             tfd()
  445.         end
  446.     end
  447.     turtle.turnLeft()
  448.     tfd()
  449.     turtle.turnRight() 
  450. end
  451.  
  452. function restocktorches()                   --Controls whether the hopper at the restock chests will load more torches into turtle
  453.     if turtle.getItemCount(torch) > 31 then
  454.         rs.setOutput('right',true)
  455.     else
  456.         rs.setOutput('right',false)
  457.     end
  458. end
  459.  
  460. function moveover()             --Once turtle is done with branch, this function makes it return to the trunk and position itself for the next branch
  461.     tup()
  462.     turtle.turnRight()
  463.     turtle.turnRight()
  464.     turtle.select(torch)
  465.     remainder = (length/(2*(13-msll)-math.floor(length/(2*(13-msll)))*(2*(13-msll))))
  466.     for i = length,1,-1 do
  467.         tfd()
  468.         if i == length and remainder <(12-msll) then        --Removes excess torches that are not needed. Light level will stay above msll
  469.             turtle.digDown()
  470.         elseif i/(13-msll) == math.floor(i/(13-msll)) and i/(2*(13-msll)) ~= math.floor(i/(2*(13-msll))) then
  471.             turtle.digDown()
  472.         end
  473.     end
  474.     if direction == 'l' then
  475.         turtle.turnRight()
  476.     else
  477.         turtle.turnLeft()
  478.     end
  479.     for i = 1,5*turtles do
  480.         turtle.forward()
  481.     end
  482.     turtle.down()
  483.     if direction == 'l' then
  484.         turtle.turnRight()
  485.     else
  486.         turtle.turnLeft()
  487.     end
  488. end
  489.  
  490. function progress(i)            --Function to display progress bar while mining
  491.     percent = (i+1)/length
  492.     clc()
  493.     print('Mining in progress...')
  494.     print()
  495.     print()
  496.     print('<                                   >')
  497.     term.setCursorPos(2,4)
  498.     bar = math.ceil(percent*35)
  499.     for j = 1,bar do
  500.         write('=')
  501.     end
  502.     term.setCursorPos(17,5)
  503.     print(tostring(percent*100-percent*100%0.1)..'%')
  504. end
  505. ---------------------------------------
  506. -----------------CODE------------------
  507. ---------------------------------------
  508.  
  509. local args = {...}
  510.  
  511. stone = 1    --Slot index for materials
  512. cobble = 2  
  513. torch = 3    
  514. fuel = 16              
  515.  
  516. helptext = {
  517. 'Safebranch is designed to mine out a ','branch mine with 3x3 tunnels with ','multiple turtles mining their own ','branches simultaneously. As they mine, ','they will remove any ores from the ','walls, and fill in empty space to block ','off natural caverns, water, lava, etc. ','In addition, they will place down ','torches periodically to prevent mobs ','from spawning. To work as intended, it ','is recommended to have at least 3 ','turtles going at a time (1 on the main ','"trunk" of the mine, and 1 for each ','branch on either side, but you can use ','as few as 1 turtle with manual ','placement after each tunnel. Below is a','diagram of the intended usage. The Ds ','represent walls, with "dashed" lines ','representing the excavation path of the','turtles.',' ','            D   D',' sideshaft','            D   D',' ','            D   D','DDDDDDDDDDDDDDDDD D D D D D D D','              T D','               TD    mainshaft','              T D','DDDDDDDDDDDDDDDDD D D D D D D D','            D   D',' ','            D   D',' sideshaft','            D   D',' '}          
  518.              
  519. if #args == 0 then   --If no arguments, give a text prompt instead
  520.     print('Is this a side branch or the main shaft? ')
  521.     write('Type main or side: ')
  522.     tunneltype = string.lower(read())
  523.     print()
  524.     print('How long do you want the tunnel to be?')
  525.     write('Enter a number greater than 0: ')
  526.     length = tonumber(read())
  527.     if tunneltype == 'side' then
  528.         print()
  529.         print('Once the turtle is finished, should it move to the left or right to start the next one?')
  530.         write('Type either L or R: ')
  531.         direction = string.lower(read())
  532.         print()
  533.         print('How many turtles (including this one) are on this side of the branch mine?')
  534.         write('Enter a number greater than 0: ')
  535.         turtles = tonumber(read())
  536.     end
  537.     write('What is the minimum safe light level (8 or 1): ')
  538.     msll = tonumber(read())
  539. elseif string.lower(args[1]) == 'help' then
  540.     clc()
  541.     textutils.pagedTabulate(helptext)
  542.     return
  543. elseif #args == 2 then
  544.     if string.lower(args[1]) ~= 'main' then
  545.         usage()
  546.         return
  547.     end
  548.     tunneltype = string.lower(args[1])
  549.     length = tonumber(args[2])
  550.     msll = 1
  551. elseif string.lower(args[1]) == 'side' and tonumber(args[2]) > 0 and (string.lower(args[3]) == 'l' or string.lower(args[3]) == 'r') and tonumber(args[4]) >= 1 and tonumber(args[5]) then
  552.     tunneltype = string.lower(args[1])
  553.     length = tonumber(args[2])
  554.     direction = string.lower(args[3])
  555.     turtles = tonumber(args[4])
  556.     msll = tonumber(args[5])
  557. else
  558.     usage()
  559.     return
  560. end
  561.  
  562. clc()
  563.  
  564. for i = 0,length-1 do
  565.     checkstock(i)       --Checks to make sure turtle has enough materials
  566.     if i ~= 0 then      --Checks to see if turtle needs to place a torch behind itself
  567.         if tunneltype == 'main' and i/5 == math.floor(i/5) then
  568.             placetorch()
  569.         elseif tunneltype == 'side' and i/(13-msll) == math.floor(i/(13-msll)) then
  570.             placetorch()
  571.         end
  572.     end
  573.    
  574. --Middle column of slice   
  575.     tfd()
  576.     cfd()
  577.     cdn()
  578.     tup()
  579.     cfd()
  580.     tup()
  581.     cfd()
  582.     cup()
  583.     turtle.turnLeft()
  584.    
  585. --Left column of slice
  586.     tfd()
  587.     cfd()
  588.     cup()
  589.     turtle.turnRight()
  590.     cfd()
  591.     tdn()
  592.     cfd()
  593.     turtle.turnLeft()
  594.     cfd()
  595.     tdn()
  596.     cfd()
  597.     cdn()
  598.     turtle.turnRight()
  599.     cfd()
  600.     turtle.turnRight()
  601.    
  602. --Right column of slice
  603.     tfd()
  604.     tfd()
  605.     cfd()
  606.     cdn()
  607.     turtle.turnLeft()
  608.     cfd()
  609.     tup()
  610.     cfd()
  611.     turtle.turnRight()
  612.     cfd()
  613.     tup()
  614.     cfd()
  615.     cup()
  616.     turtle.turnLeft()
  617.     cfd()
  618.     turtle.turnLeft()
  619.     tfd()
  620.     turtle.turnRight()
  621.     tdn()
  622.     tdn()
  623.    
  624.     progress(i)     --Update progress bar
  625.    
  626.     if i == length-1 then   --Place torch at end of tunnel
  627.         placetorch()
  628.         if tunneltype == 'side' then
  629.             moveover()
  630.         end
  631.     end
  632. end
  633.  
  634. turtle.select(1)
Comments
Add Comment
Please, Sign In to add comment