View difference between Paste ID: F86LjZrh and 5U7Sd6RX
SHOW: | | - or go back to the newest paste.
1
------Tunneling Automaton - V2------
2
3
----Variables----
4
5
t = turtle
6-
orientation = 1
6+
7
----Basic Controls----
8
9
function digForward()
10-
--Turning--
10+
11-
function turnLeft()
11+
12-
	if orientation == 4 then
12+
13-
		orientation = 0
13+
14
end
15-
		orientation = orientation + 1
15+
16
	if t.detect() then
17-
	t.turnLeft()
17+
18
		moveForward()
19-
function turnRight()
19+
20-
	if orientation == 1 then
20+
21-
		orientation = 4
21+
22
end
23-
		orientation = orientation - 1
23+
24
function length()
25-
	t.turnRight()
25+
    num = t.getItemCount(2)
26
    return num
27
end
28-
function reorient()
28+
29-
	if orientation == 2 then
29+
function refuel()
30-
		turnLeft()
30+
31-
	elseif orientation == 3 then
31+
	t.refuel(1)
32-
		turnLeft()
32+
33-
		turnLeft()
33+
34-
	elseif orientation == 4 then
34+
----Bridge----
35-
		turnRight()
35+
36
function bridge()
37
	t.select(2)
38
	num = length()
39-
--Digging--
39+
40-
function digUp()
40+
		goForward()
41-
	t.digUp()
41+
		t.placeDown()
42
		num = num - 1
43-
function digDown()
43+
44-
	t.digDown()
44+
45
46
----Main----
47
function main()
48
	refuel()
49-
function digLeft()
49+
	bridge()
50-
	turnLeft()
50+
51-
	digForward()
51+
52
--Run--
53-
function digRight()
53+