View difference between Paste ID: 3bbhnXLP and vSWz3kdk
SHOW: | | - or go back to the newest paste.
1
n1 = 0
2
n2 = 0
3
function text()
4
5
shell.run("clear")
6
print("fuel level: ".. turtle.getFuelLevel())
7
io.write "turtle will stop when this number reaches zero: "
8
io.write (n3)
9
print ""
10
print ""
11
print "or when the last slot in it's inventory is in use."
12
13
end
14
15
16
function Return()
17
18
repeat
19
turtle.back()
20
n2 = n2 - 1
21
until n2 == 0
22
23
end
24
25
26
function dig()
27
28
if turtle.getFuelLevel() < 3 then
29
	for i = 1,16 do
30
		if turtle.getItemCount(i) > 0 then
31
			turtle.select(i)
32
			if turtle.refuel(1) then
33
				break
34
			end
35
		end
36
	end
37
	turtle.select(1)
38
end
39
40
if turtle.detectUp() == true then
41
turtle.digUp()
42
elseif turtle.detectDown() == true then
43
turtle.digDown()
44
else
45
n1 = n1 + 1
46
if n1 == 1 then
47
turtle.turnLeft()
48
while true do
49
if turtle.detect() == true then
50
turtle.dig()
51
else
52
break
53
end
54
sleep(0.4)
55
end
56
turtle.forward()
57
elseif n1 == 2 then
58
turtle.back()
59
turtle.turnRight()
60
turtle.turnRight()
61
while true do
62
if turtle.detect() == true then
63
turtle.dig()
64
else
65
break
66
end
67
sleep(0.4)
68
end
69
turtle.forward()
70
elseif n1 == 3 then
71
turtle.back()
72
turtle.turnLeft()
73
elseif n1 == 4 then
74
while true do
75
if n3 == 1 then
76
break
77
elseif turtle.getItemCount(16) ~= 0 then
78
n3 = 1
79
break
80
elseif turtle.detect() == true then
81
turtle.dig()
82
sleep(0.4)
83
else
84
break
85
end
86
end
87
turtle.forward()
88
n1 = 0
89
n3 = n3 - 1
90
n2 = n2 + 1
91
end
92
end
93
sleep(0.4)
94
95
end
96
97
98
function start()
99
100
shell.run("clear")
101
io.write "how long do you want the tunnel: "
102
n3 = io.read()
103
n3 = tonumber(n3)
104
while true do
105
if turtle.detect() == true then
106
turtle.dig()
107
sleep(0.4)
108
else
109
break
110
end
111
end
112
turtle.forward()
113
shell.run("clear")
114
115
end
116
117
-- NO MORE FUNCTIONS :D
118
119
start()
120
while true do
121
text()
122
dig()
123
if n3 == 0 then
124
break
125
end
126
127
end
128
Return()
129
text()
130
sleep(2)
131
shell.run("clear")
132
print "DONE!"
133
print "or out of inventory..."