View difference between Paste ID: 2bxBRRjK and UPGKbXPL
SHOW: | | - or go back to the newest paste.
1
t = turtle
2
function moveForward()
3
	if t.detect() then
4
		t.dig()
5
		t.forward()
6
	else
7
		t.forward()
8
	end
9
end
10
function moveUpward()
11
	if t.detectUp() then
12
		t.digUp()
13-
function moveDistance(distance)
13+
14
	else
15
		t.up()
16
	end
17
end
18
function fuelTurtle(distance)
19
	t.refuel(distance/80)
20
end
21
function moveDistanceForward(distance)
22
	while distance > 0 do
23
		moveForward()
24
		distance = distance - 1
25
	end
26
end
27
function moveDistanceUpward(distance)
28
	while distance > 0 do
29
		moveUpward()
30
		distance = distance - 1
31
	end
32
end
33
function distanceInput()
34
  num = io.read()
35
  num = tonumber(num)
36
  return num
37
end
38
function turnAround()
39
	t.turnLeft()
40
	t.turnLeft()
41
end
42
function moveUp()
43
	if t.detectUp() then
44
		t.digUp()
45
		t.up()
46
	else
47
		t.up()
48
	end
49
end
50
51
function shaft()
52
	print("Input distance: ")
53
	distance = distanceInput()
54
	fuelTurtle(distance)
55
	moveDistanceForward(distance)
56
	t.refuel(1)
57
	moveUp()
58
	turnAround()
59
	fuelTurtle(distance)
60
	moveDistance(distance)
61
end
62
63
function hole()
64
	print("Input distance: ")
65
	distance = distanceInput()
66
	fuelTurtle(distance)
67
	
68
69
function main()
70
	print("1 = Shaft, 2 = Hole")
71
	func = io.read()
72
	func = tonumber(func)
73
	if func == 1 then
74
		shaft()
75
	elif func == 2 then
76
		hole()
77
	end
78
end
79
80
main()