View difference between Paste ID: eLbHURej and EnsJnp0d
SHOW: | | - or go back to the newest paste.
1
t = turtle
2-
function miF()
2+
function moveForward()
3-
  if t.detect() then
3+
	if t.detect() then
4-
    t.dig()
4+
		t.dig()
5-
  end
5+
		t.forward()
6
	end
7-
function moF()
7+
	else
8-
  if not t.detect() then
8+
		t.forward()
9-
    t.forward()
9+
	end
10-
  end
10+
11
function fuelTurtle(distance)
12-
function mmF()
12+
	t.refuel(distance/80)
13-
  miF()
13+
14-
  moF()
14+
function moveDistance(distance)
15
	while distance > 0 do
16-
function miU()
16+
		moveForward()
17-
  if t.detectUp() then
17+
		distance = distance - 1
18-
    t.digUp()
18+
function distanceInput()
19-
  end
19+
20
  num = tonumber(num)
21-
function mm()
21+
22-
  mmF()
22+
23-
  miU()
23+
function turnAround()
24
	t.turnLeft()
25-
function fu(num)
25+
	t.turnLeft()
26-
  t.refuel(num/40)
26+
27
function moveUp()
28-
function go(num)
28+
	if t.detectUp() then
29-
  while num > 0 do
29+
		t.digUp()
30-
    mm()
30+
		t.up()
31-
    num = num - 1
31+
	end
32-
    if not t.detectDown() then
32+
	else
33-
      t.placeDown()
33+
		t.up()
34-
    end
34+
	end
35-
  end
35+
function main()
36
	distance = distanceInput()
37-
function dis()
37+
	fuelTurtle(distance)
38
	moveDistance(distance)
39
	moveUp()
40
	t.refuel(1)
41
	turnAround()
42-
function a()
42+
	fuelTurtle(distance)
43-
  print("Input distance: ")
43+
	moveDistance(distance)
44-
  num = dis()
44+
45-
  fu(num)
45+
46-
  go(num)
46+
main()