View difference between Paste ID: QScvBW0c and eLbHURej
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
	end
7
	else
8
		t.forward()
9
	end
10
end
11
function fuelTurtle(distance)
12
	t.refuel(distance/80)
13
end
14
function moveDistance(distance)
15
	while distance > 0 do
16
		moveForward()
17
		distance = distance - 1
18
function distanceInput()
19
  num = io.read()
20
  num = tonumber(num)
21
  return num
22
end
23
function turnAround()
24
	t.turnLeft()
25
	t.turnLeft()
26
end
27
function moveUp()
28
	if t.detectUp() then
29
		t.digUp()
30
		t.up()
31
	end
32
	else
33
		t.up()
34
	end
35
function main()
36
	distance = distanceInput()
37
	fuelTurtle(distance)
38
	moveDistance(distance)
39
	t.refuel(1)
40
	moveUp()
41
	turnAround()
42
	fuelTurtle(distance)
43
	moveDistance(distance)
44
end
45
46
main()