CCCPaste

MDC_Tunnel_Facing

-- This program creates a tunnel facing to facilitate mining via 5 x 5 tunnels
-- Pastebin code = "LptADyfD"; Pastebin name is "MDC_Tunnel_Facing"

-- Place the turtle down on the right-forward end of the tunnel cut
-- Place coal into Turtle slot #14 to assure adequate fueling
-- Place netherite into Turtle slot #15 and #16 to assure adequate placement resources
-- The program wants to know the options how many blocks you want to move forward before facing
-- The options are RC - Right Corner; LC - Left Corner; CS - Center Section
-- An example is RC 2; Right corner facing two blocks forward from turtle placement

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[2] ) < 0 ) then
    print( "Error: You must respond with zero or a positive number." )
	return
    end

option = text_input[1]
move_forward = tonumber( text_input[2] )
desired_height = 5
desired_width = 5

for iter1 = 1, move_forward do mv_fwd; end

if option == "LC" then 

	for iter2 = 1, desired_ height do -- Face a hallway for the left corner and one block

		turtle.turnLeft() -- Position turtle for initial facing

		for iter3 = 1, ( desired_height + 1 ) do -- Face blocks up the left side
			place_fwd(); mv_up()
		end

		turtle.turnRight()

		for iter4 = 1, (desired_height + 1 ) do -- Face blocks down the left front column
			place_fwd(); mv_dwn()
		end

	end

end

print("Program has completed successfully."