View difference between Paste ID: zsksAPPq and sawWmevr
SHOW: | | - or go back to the newest paste.
1
function cPrint(str)
2
    term.clear()
3
    term.setCursorPos(1,1)
4
    print(str)
5
end
6
7
cPrint('starting up quarry!')
8
os.sleep(1)
9
cPrint('')
10
11
os.loadAPI('nav.lua')
12
nav.calibrate()
13
14
function goBack(functionCalled)
15-
    initx, inity, initz = nav.pos.x, nav.pos.y, nav.pos.z
15+
    initx, inity, initz, initDir = nav.pos.x, nav.pos.y, nav.pos.z, nav.pos.dir
16
    if nav.pos.z ~= 0 then
17
        nav.up(math.abs(nav.pos.z))
18
    end
19-
    while not nav.pos.dir == 2 do
19+
    nav.goDir(2)
20-
        nav.turnRight()
20+
21
        nav.forward(math.abs(nav.pos.y))
22
    end
23
    if nav.pos.x ~= 0 then
24
        if nav.pos.x < 0 then
25
            nav.goDir(1)
26
            nav.forward(math.abs(nav.pos.x))
27-
            while nav.pos.dir ~= 1 do
27+
28-
                nav.turnRight()
28+
            nav.goDir(3)
29-
            end
29+
30
        end
31
    end
32-
            while nav.pos.dir ~= 3 do 
32+
33-
                nav.turnRight()    
33+
    nav.turnRight(2)
34-
            end
34+
	nav.forward(inity)
35
	if initx/math.abs(initx) = -1 do
36
		nav.turnLeft(1)
37
	elseif initx/math.abs(initx) = 1 do
38
		nav.turnRight(1)
39-
    
39+
	end
40
	if initx ~= 0 then
41
		nav.forward(math.abs(initx))
42
	end
43-
    if turtle.getFuelLevel() < 200 then
43+
	nav.down(initz)
44
	nav.goDir(initDir)
45
end
46
47
function refuel()
48
    if turtle.getFuelLevel() < 2*(math.abs(nav.pos.z) + math.abs(nav.pos.y) + math.abs(math.pos.x) + 10) then
49
        if not turtle.refuel() then
50
            goBack(grabFuel)
51
        end
52
    end
53-
        if checkFuel() == then
53+
54
55-
        if checkInv == then
55+
function checkInv()
56
	if turtle.getItemCount(16) ~= 0 then
57-
    end
57+
		goBack(dropOff)
58
	end
59
end
60
61
function grabFuel()
62
	turtle.suckUp(64)
63
end
64
65
function dropOff()
66
	for i=2, 16 do
67
		turtle.select(i)
68
		turtle.drop(64)
69
	end
70
	turtle.select(1)
71
end
72
	
73
function forward(x)
74
    for i = 1, x do
75
        nav.forward(1)
76
        refuel()
77
        checkInv()
78
    end
79
end