View difference between Paste ID: LptADyfD and yqYhZdbF
SHOW: | | - or go back to the newest paste.
1-
-- This program creates a tunnel liner to facilitate mining via 5 x 5 tunnels
1+
-- This program creates a tunnel facing to facilitate mining via 5 x 5 tunnels
2-
-- Pastebin code = "yqYhZdbF"; Pastebin name is "MDC_Tunnel_Liner"
2+
-- Pastebin code = "LptADyfD"; Pastebin name is "MDC_Tunnel_Facing"
3
4-
-- Place the turtle down on the right-forward end of the tunnel cut.
4+
-- Place the turtle down on the right-forward end of the tunnel cut
5
-- Place coal into Turtle slot #14 to assure adequate fueling
6-
-- Place stone into Turtle slot #15 and #16 to assure adequate placement resources
6+
-- Place netherite into Turtle slot #15 and #16 to assure adequate placement resources
7-
-- This program begins by asking you how many two-block sections you want to cut
7+
-- The program wants to know the options how many blocks you want to move forward before facing
8
-- The options are RC - Right Corner; LC - Left Corner; CS - Center Section
9
-- An example is RC 2; Right corner facing two blocks forward from turtle placement
10
11
local function mv_fwd() -- This function moves the turtle forward one block
12
	if turtle.detect() then turtle.dig(); turtle.forward() else turtle.forward() end
13
	end
14
15
local function mv_up() -- This function moves the turtle up one block
16
	if turtle.detectUp() then turtle.digUp(); turtle.up() else turtle.up() end
17
	end
18
19
local function mv_dwn() -- This function moves the turtle down one block
20
	if turtle.detectDown() then turtle.digDown(); turtle.down() else turtle.down() end
21
	end
22
23
local function sel_slot() -- This function selects the active slot for placing blocks
24
	turtle.select(15)
25
	if turtle.getItemCount() < 3 then turtle.select(16) end
26
	end
27
28
local function place_fwd() -- This function places a block if none is present in front of the turtle
29
	if not turtle.detect() then sel_slot(); turtle.place() end -- check forward and place
30
	end
31
32
local function place_up()
33
	if not turtle.detectUp() then sel_slot(); turtle.placeUp() end -- check up and place
34
	end
35
36
local function place_dwn()
37
	if not turtle.detectDown() then sel_slot(); turtle.placeDown() end -- check down and place
38
	end
39
40
local function place_LC()
41
	turtle.turnLeft() -- Position turtle for initial facing
42
43
	for iter3 = 1, desired_height do -- Face blocks up the left side
44
		place_fwd(); mv_up()
45
	end
46
47-
if ( tonumber( text_input[1] ) < 1 ) then
47+
	place_fwd(); turtle.turnRight(); place_fwd(); mv_dwn(); place_up()
48-
    print( "Error: You must respond with a positive number." )
48+
49
	for iter4 = 2, desired_height do -- Face blocks down the left front column
50
		place_fwd(); mv_dwn()
51
	end
52-
desired_sets = tonumber( text_input[1] )
52+
53
	place_fwd(); place_dwn()
54
55
	end
56-
while desired_sets > 0 do
56+
57
local function place_CS()
58-
	for iter1 = 1, desired_sets do -- Cut a hallway for the desired length while filling sides
58+
59
	place_dwn()
60-
		mv_fwd(); turtle.turnRight() -- Position turtle for initial cutting and placing
60+
61
	for iter5 = 1, desired_height do -- Face blocks up the left-center
62-
		for iter2 = 1, ( desired_height + 1 ) do -- Cut and place blocks up right side
62+
		place_fwd(); mv_up()
63-
			place_fwd(); mv_up()
63+
64-
		end
64+
65
	place_fwd(); mv_dwn(); place_fwd(); place_up(); 
66-
		turtle.turnLeft(); turtle.turnLeft(); -- Position turtle for cutting and placing on top of tunnel
66+
	turtle.turnRight();	mv_fwd(); turtle.turnLeft(); place_up()
67-
		mv_dwn(); mv_dwn()
67+
68
	for iter6 = 2, desired_height do -- Face blocks down the center
69-
		for iter3 = 1, ( desired_width + 1 ) do -- Cut and place blocks across the top
69+
		place_fwd(); mv_dwn()
70-
			place_up(); mv_fwd()
70+
71-
		end
71+
72
	place_fwd(); place_dwn(); turtle.turnRight(); mv_fwd(); turtle.turnLeft()
73-
		turtle.turnLeft(); turtle.turnLeft(); mv_fwd(); mv_fwd(); turtle.turnLeft(); turtle.turnLeft();
73+
74
	for iter7 = 1, desired_height do -- Face blocks up the right-center
75-
		for iter4 = 1, desired_height do -- Cut and place blocks down the left side
75+
		place_fwd(); mv_up()
76-
			if not ( iter4 == desired_height ) then place_fwd(); mv_dwn() else place_fwd() end
76+
77-
		end
77+
78
	mv_dwn(); place_up(); for iter8 = 2, desired_height do mv_dwn() end
79-
		turtle.turnRight(); mv_fwd(); turtle.turnLeft()  -- Position turtle for cutting and placing up the left side
79+
80
	place_dwn()
81-
		for iter5 = 1, ( desired_height + 1 ) do -- Cut and place blocks up the 2nd left side
81+
82-
			place_fwd(); mv_up()
82+
83-
		end
83+
84
local function place_RC()
85-
		turtle.turnRight(); turtle.turnRight(); mv_dwn(); mv_dwn()
85+
86
	for iter8 = 1, desired_height do -- Face blocks up the right face
87-
		for iter6 = 1, ( desired_width + 1 ) do -- Cut and place blocks back across the top
87+
		place_fwd(); mv_up()
88-
			place_up(); mv_fwd()
88+
89-
		end
89+
90
	place_fwd(); turtle.turnRight(); place_fwd(); mv_dwn(); place_up()
91-
		turtle.turnLeft(); turtle.turnLeft(); mv_fwd(); mv_fwd(); turtle.turnLeft(); turtle.turnLeft();
91+
92
	for iter9 = 2, desired_height do -- Face blocks down the right side
93-
		for iter4 = 1, desired_height do -- Cut and place blocks down the right side
93+
		place_fwd(); mv_dwn()
94-
			if not ( iter4 == desired_height ) then place_fwd(); mv_dwn() else place_fwd() end
94+
95-
		end
95+
96
	place_fwd(); place_dwn(); turtle.turnLeft()
97
98-
		turtle.turnLeft(); desired_sets = ( desired_sets - 1 )
98+
99
100
if turtle.getFuelLevel() < 200 then
101
    print( "Your fuel level is less than 200; refueling with 240." )
102
    turtle.select(14); turtle.refuel(3)
103
    end
104-
print( "The program has ended successfully." )
104+
105
text_input = { ... } -- Obtain the number of two-block sections desired
106
107
print ( "Checking Data Entered." )
108
109
if ( tonumber( text_input[2] ) < 0 ) then
110
    print( "Error: You must respond with zero or a positive number." )
111
	return
112
    end
113
114
option = text_input[1]
115
move_forward = tonumber( text_input[2] )
116
desired_height = 5
117
desired_width = 5
118
119
for iter1 = 1, move_forward do mv_fwd(); end
120
121
if option == "All" then 
122
123
	place_LC()
124
	turtle.turnRight(); mv_fwd(); turtle.turnLeft()
125
126
	place_CS()
127
	turtle.turnRight(); mv_fwd(); turtle.turnLeft()
128
129
	place_RC()
130
	turtle.turnLeft(); turtle.forward(); turtle.forward()
131
	turtle.forward(); turtle.forward(); turtle.forward()
132
	turtle.turnRight()
133
134
end
135
136
-- if option == "CS" then
137
-- end
138
139
if option == "RC" then 
140
141
	place_RC()
142
143
end
144
145
print("Program has completed successfully.")