View difference between Paste ID: 6ii2abYU and KfJHQycJ
SHOW: | | - or go back to the newest paste.
1
refill = function()
2
	turtle.select(1)
3
	if turtle.getFuelLevel()  < 50 then
4
		repeat
5-
			sleep()
5+
			sleep(3)
6-
			destroy()
6+
7
			turtle.placeUp()
8
			turtle.suckUp()
9
			turtle.refuel(64)
10
			turtle.dropUp()
11
			turtle.digUp()
12
		until turtle.getFuelLevel() > 50
13
	end
14
end
15
lastempty = function()
16
	turtle.digUp()
17
	turtle.select(2)
18
	turtle.placeUp()
19
	for i = 3, 16, 1
20
	do
21
		turtle.select(i)
22
		turtle.dropUp(64)
23
	end
24
	turtle.select(2)
25
	turtle.digUp()
26
	turtle.select(1)
27
end
28
empty = function()
29
	if turtle.getItemCount(15) >= 1 then
30
		turtle.digUp()
31
		turtle.select(2)
32
		turtle.placeUp()
33
		for i = 3, 16, 1
34
		do
35
			turtle.select(i)
36
			turtle.dropUp(64)
37
		end
38
		turtle.select(2)
39
		turtle.digUp()
40
		turtle.select(1)
41
	end
42
end
43
44
destroy = function()
45
	empty()
46
	turtle.digDown()
47
	turtle.digUp()
48
	while turtle.detect() == true do
49
		turtle.dig()
50
	end
51
end
52
lastdestroy = function()
53
	empty()
54
	turtle.digUp()
55
	turtle.digDown()
56
end
57
row = function(distance)
58
	for i = 0, distance, 1
59
	do
60
		destroy()
61
		refill()
62
		turtle.forward()
63
	end
64
end
65
righthook = function()
66
	empty()
67
	turtle.turnRight()
68
	destroy()
69
	refill()
70
	turtle.forward()
71
	turtle.turnRight()
72
end
73
lefthook = function()
74
	empty()
75
	turtle.turnLeft()
76
	destroy()
77
	refill()
78
	turtle.forward()
79
	turtle.turnLeft()
80
end
81
square = function(Length, Depth)
82
	empty()
83
	if Length % 2 == 0 then
84
		for i = 1, Length, 2
85
		do
86
			row(Depth)
87
			righthook()
88
			row(Depth)
89
			lefthook()
90
		end
91
		row(Depth)
92
		righthook()
93
		row(Depth)
94
		lastdestroy()
95
		turtle.turnRight()
96
		for i = 0, Length, 1
97
		do
98
			refill()
99
			turtle.forward()
100
		end
101
		turtle.turnRight()
102
	elseif Length % 2 ~= 0 then
103
		for i = 0, Length, 2
104
		do
105
			row(Depth)
106
			righthook()
107
			row(Depth)
108
			lefthook()
109
		end
110
		row(Depth)
111
		lastdestroy()
112
		turtle.turnLeft()
113
		turtle.turnLeft()
114
		for i = 0, Depth, 1
115
		do
116
			refill()
117
			turtle.forward()
118
		end
119
		turtle.turnRight()
120
		for i = 0, Length, 1 
121
		do
122
			refill()
123
			turtle.forward()
124
		end
125
		turtle.turnRight()
126
	elseif Length == 0 then
127
		row(Depth)
128
		turtle.turnLeft()
129
		turtle.turnLeft()
130
		for i = 0, Depth, 1
131
		do
132
			refill()
133
			turtle.forward()
134
		end
135
		turtle.turnRight()
136
		turtle.turnRight()
137
	elseif Depth == 0 then
138
		turtle.turnRight()
139
		row(Length)
140
		turtle.turnLeft()
141
		turtle.turnLeft()
142
		for i = 0, Length, 1
143
		do
144
			refill()
145
			turtle.forward()
146
		end
147
		turtle.turnRight()
148
	end
149
	lastempty()
150
end
151
152
term.write("Select Depth: ")
153
local depth = read()
154
depth = depth - 2
155
term.write("Select Length: ")
156
local length = read()
157
length = length - 2
158
159
refill()
160
square(length, depth)
161
print("Mining Completed")