View difference between Paste ID: Zm3u3NQF and F86LjZrh
SHOW: | | - or go back to the newest paste.
1
------Tunneling Automaton - V2------
2
3
----Variables----
4
5
t = turtle
6
7
----Basic Controls----
8
9-
function digForward()
9+
10-
	t.digForward()
10+
11
		t.digForward()
12-
function moveForward()
12+
		t.forward()
13-
	t.forward()
13+
14
		t.forward()
15
	end
16
end
17-
		digForward()
17+
function goDown()
18-
		moveForward()
18+
	if t.detectDown() then
19
		t.digDown()
20-
		moveForward()
20+
		t.down()
21
	else
22
		t.down()
23
	end
24
end
25-
    num = t.getItemCount(2)
25+
function goUp()
26
	if t.detectUp() then
27
		t.digUp()
28
		t.up()
29
	else
30
		t.up()
31-
	t.refuel(1)
31+
32
end
33
34
function refuel()
35
	t.select(1)
36-
function bridge()
36+
	t.refuel()
37-
	t.select(2)
37+
38
39
function length()
40-
		goForward()
40+
	num = io.read()
41-
		t.placeDown()
41+
    num = tonumber(num)
42
    return num
43
end
44
45
----Bridge----
46
47
function layers()
48
	num = length()
49-
	bridge()
49+
	copynum = num
50
	while num > 0 do
51
		goDown()
52
		nut = 4
53
		while nut > 0 do
54
			goForward()
55
			goForward()
56
			t.turnLeft()
57
			nut = nut - 1
58
		end
59
		num = num - 1
60
	end
61
	goForward()
62
	t.turnLeft()
63
	goForward()
64
	while copynum > 0 do
65
		goUp()
66
	end
67
end
68
69
----Main----
70
function main()
71
	refuel()
72
	layers()
73
end
74
75
--Run--
76
main()