View difference between Paste ID: ufgTjqx7 and 3n5XrKdP
SHOW: | | - or go back to the newest paste.
1-
------Tunneling Automaton------
1+
------Tunneling Automaton - V2------
2
3
----Variables----
4
5
t = turtle
6
orientation = 1
7
8-
----Basic Digging and Control Operations----
8+
----Basic Controls----
9
10-
--Orientation change, 1 is forward by initialization--
10+
--Turning--
11-
function OCL()
11+
function turnLeft()
12
	if orientation == 4 then
13
		orientation = 0
14
	else
15
		orientation = orientation + 1
16
	end
17
	t.turnLeft()
18-
function OCR()
18+
19
function turnRight()
20
	if orientation == 1 then
21
		orientation = 4
22
	else
23
		orientation = orientation - 1
24
	end
25
	t.turnRight()
26-
--Turning Left and Right--
26+
27-
function TLE()
27+
28
function reorient()
29-
	OCL()
29+
30
		turnLeft()
31-
function TRI()
31+
32
		turnLeft()
33-
	OCR()
33+
		turnLeft()
34
	elseif orientation == 4 then
35
		turnRight()
36-
--Reorienting efficiently--
36+
37-
function REO()
37+
38
39-
		TLE()
39+
--Digging--
40
function digUp()
41-
		TLE()
41+
42-
		TLE()
42+
43
function digDown()
44-
		TRI()
44+
45
end
46
function digForward()
47
	t.digForward()
48-
--Digging in Basic Directions--
48+
49-
function DUP()
49+
function digLeft()
50
	turnLeft()
51
	digForward()
52-
function DDO()
52+
53
function digRight()
54
	turnRight()
55-
function DFO()
55+
	digForward()
56
end
57
58
--Moving--
59-
--Moving in Basic Directions--
59+
function moveUp()
60-
function MUP()
60+
61
end
62
function moveDown()
63-
function MDO()
63+
64
end
65
function moveForward()
66-
function MFO()
66+
67
end
68
function moveLeft()
69
	turnLeft()
70-
--Digging Left and Right--
70+
	moveForward()
71-
function DRI()
71+
72-
	TRI()
72+
function moveRight()
73-
	DFO()
73+
	turnRight()
74
	moveFoward()
75-
function DLE()
75+
76-
	TLE()
76+
77-
	DFO()
77+
--Digging and Moving--
78
function goUp()
79
	if t.detectUp() then
80-
--Moving Left and Right--
80+
		digUp()
81-
function MRI()
81+
		moveUp()
82-
	TRI()
82+
83-
	DFO()
83+
		moveUp()
84
	end
85-
function MLE()
85+
86-
	TLE()
86+
function goDown()
87-
	DFO()
87+
88
		digDown()
89
		moveDown()
90-
--Digging and Moving Efficiently--
90+
91-
function DMU()
91+
		moveDown()
92
	end
93-
		DUP()
93+
94-
		MUP()
94+
function goForward()
95
	if t.detect() then
96-
		MUP()
96+
		digForward()
97
		moveForward()
98
	else
99-
function DMD()
99+
		moveForward()
100
	end
101-
		DDO()
101+
102-
		MDO()
102+
function goRight()
103
	turnRight()
104-
		MDO()
104+
105
		digForward()
106
		moveForward()
107-
function DMF()
107+
108
		moveForward()
109-
		DFO()
109+
110-
		MFO()
110+
111
function goLeft()
112-
		MFO()
112+
	turnLeft()
113
	if t.detect() then
114
		digForward()
115-
function DMR()
115+
		moveForward()
116-
	TRI()
116+
117
		moveForward()
118-
		DFO()
118+
119-
		MFO()
119+
120
121-
		MFO()
121+
----Inventory----
122
--Check if any slots are free--
123
function freeSlots()
124-
function DML()
124+
	num = 16
125-
	TLE()
125+
	spaceLeft = false
126
	while num > 0 do
127-
		DFO()
127+
		if t.getItemCount(num) == 0 then
128-
		MFO()
128+
			spaceLeft = true
129
		end
130-
		MFO()
130+
		num = num - 1
131
	end
132
	return spaceLeft
133
end
134-
--Input Distance--
134+
135-
function dis()
135+
function placeStorageChest()
136-
	print("Input Distance:")
136+
	t.select(1)
137-
	num = io.read()
137+
	digUp()
138-
	num = tonumber(num)
138+
	t.placeUp()
139-
	return num
139+
140
function placeFuelChest()
141
	t.select(2)
142-
--Refuel based on distance--
142+
	digUp()
143-
function fuel(distance)
143+
	t.placeUp()
144
end
145
function placeChunkLoader()
146
	t.select(3)
147-
----Advanced Mining Operations----
147+
	digUp()
148
	t.placeUp()
149-
function tunnel(distance)
149+
150-
	if not t.getFuelLevel() >= distance then
150+
151-
		fuel(distance-t.getFuelLevel())
151+
function getFuel()
152
	t.select(2)
153-
	while distance > 0 do
153+
	t.suckUp(10)
154-
		DMF()
154+
155-
		DUP()
155+
function store()
156-
		distance = distance - 1
156+
	num = 16
157
	while num > 3 do
158
		t.dropUp()
159
		num = num - 1
160-
function hole(distance)
160+
161-
	if not (t.getFuelLevel() >= distance) then
161+
162-
		fuel(distance-t.getFuelLevel())
162+
function fuel()
163
	t.select(2)
164-
	while distance > 0 do
164+
165-
		DMD()
165+
166-
		distance = distance - 1
166+
167
----Mining----
168
function shaft
169
//ADD mining shaft, add check fuel left and refill, add chunk loaders
170
----Main Loop----
171
function main()
172-
	hole(dis())
172+
	
173
end
174
--Run--
175
main()