Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- This program creates a tunnel liner to facilitate mining via 5 x 5 tunnels
- -- Pastebin code = "yqYhZdbF"; Pastebin name is "MDC_Tunnel_Liner"
- -- Place the turtle down on the right-forward end of the tunnel cut.
- -- Place coal into Turtle slot #14 to assure adequate fueling
- -- Place stone into Turtle slot #15 and #16 to assure adequate placement resources
- -- This program begins by asking you how many two-block sections you want to cut
- local function mv_fwd() -- This function moves the turtle forward one block
- if turtle.detect() then turtle.dig(); turtle.forward() else turtle.forward() end
- end
- local function mv_up() -- This function moves the turtle up one block
- if turtle.detectUp() then turtle.digUp(); turtle.up() else turtle.up() end
- end
- local function mv_dwn() -- This function moves the turtle down one block
- if turtle.detectDown() then turtle.digDown(); turtle.down() else turtle.down() end
- end
- local function sel_slot() -- This function selects the active slot for placing blocks
- turtle.select(15)
- if turtle.getItemCount() < 3 then turtle.select(16) end
- end
- local function place_fwd() -- This function places a block if none is present in front of the turtle
- if not turtle.detect() then sel_slot(); turtle.place() end -- check forward and place
- end
- local function place_up()
- if not turtle.detectUp() then sel_slot(); turtle.placeUp() end -- check up and place
- end
- local function place_dwn()
- if not turtle.detectDown() then sel_slot(); turtle.placeDown() end -- check down and place
- end
- if turtle.getFuelLevel() < 200 then
- print( "Your fuel level is less than 200; refueling with 240." )
- turtle.select(14); turtle.refuel(3)
- end
- text_input = { ... } -- Obtain the number of two-block sections desired
- print ( "Checking Data Entered." )
- if ( tonumber( text_input[1] ) < 1 ) then
- print( "Error: You must respond with a positive number." )
- return
- end
- desired_sets = tonumber( text_input[1] )
- desired_height = 5
- desired_width = 5
- while desired_sets > 0 do
- for iter1 = 1, desired_sets do -- Cut a hallway for the desired length while filling sides
- mv_fwd(); turtle.turnRight() -- Position turtle for initial cutting and placing
- for iter2 = 1, ( desired_height + 1 ) do -- Cut and place blocks up right side
- place_fwd(); mv_up()
- end
- turtle.turnLeft(); turtle.turnLeft(); -- Position turtle for cutting and placing on top of tunnel
- mv_dwn(); mv_dwn()
- for iter3 = 1, ( desired_width + 1 ) do -- Cut and place blocks across the top
- place_up(); mv_fwd()
- end
- turtle.turnLeft(); turtle.turnLeft(); mv_fwd(); mv_fwd(); turtle.turnLeft(); turtle.turnLeft();
- for iter4 = 1, desired_height do -- Cut and place blocks down the left side
- if not ( iter4 == desired_height ) then place_fwd(); mv_dwn() else place_fwd() end
- end
- turtle.turnRight(); mv_fwd(); turtle.turnLeft() -- Position turtle for cutting and placing up the left side
- for iter5 = 1, ( desired_height + 1 ) do -- Cut and place blocks up the 2nd left side
- place_fwd(); mv_up()
- end
- turtle.turnRight(); turtle.turnRight(); mv_dwn(); mv_dwn()
- for iter6 = 1, ( desired_width + 1 ) do -- Cut and place blocks back across the top
- place_up(); mv_fwd()
- end
- turtle.turnLeft(); turtle.turnLeft(); mv_fwd(); mv_fwd(); turtle.turnLeft(); turtle.turnLeft();
- for iter4 = 1, desired_height do -- Cut and place blocks down the right side
- if not ( iter4 == desired_height ) then place_fwd(); mv_dwn() else place_fwd() end
- end
- turtle.turnLeft(); desired_sets = ( desired_sets - 1 )
- end
- end
- print( "The program has ended successfully." )
Advertisement