View difference between Paste ID: twpXKqyu and SNL0xiZa
SHOW: | | - or go back to the newest paste.
1
lane=0
2
write("Length: ")
3
length = read()
4
function moveForward(length)
5
  for i = 1, length do
6
        turtle.forward()
7
  end
8
end
9
function switchLanes()
10
  moveForward(1)
11
  turtle.turnRight()
12
  moveForward(2)
13
  turtle.turnRight()
14
end
15
function switchLanes2()
16
  moveForward(1)
17
  turtle.turnLeft()
18
  moveForward(4)
19
  turtle.turnLeft()
20
end
21
function dig()
22
  turtle.dig()
23
  moveForward(1)
24
  turtle.digDown()
25
end
26
function home()
27
	if lane==6 then
28
		turtle.turnLeft()
29
		moveForward(18)
30
		turtle.turnRight()
31
        lane=0
32
  end
33
		if turtle.getFuelLevel() <=1000 then
34
			turtle.down()
35
			turtle.down()
36
			turtle.suckDown()
37
			for x=1,16,1 do
38
				turtle.select(x)
39
				turtle.refuel()
40
			end
41
			turtle.up()
42
			turtle.up()
43
		sleep(120)
44
	end
45
end
46
function roam()
47
  lane=lane+1
48
  for i = 1, length do
49
        if turtle.detect() then
50
          dig()
51
        else
52
         moveForward(1)
53
        end
54
  end
55
  if lane%2==0 then
56
  	switchLanes2()
57
  else
58
  	switchLanes()
59
  end
60
  home()
61
  sleep(1)
62
end
63
64
turtle.up()
65
turtle.up()
66
67
while true do
68
  roam()
69
end