Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function cPrint(str)
- term.clear()
- term.setCursorPos(1,1)
- print(str)
- end
- cPrint('starting up quarry!')
- os.sleep(1)
- cPrint('')
- os.loadAPI('nav.lua')
- nav.calibrate()
- function goBack(functionCalled)
- initx, inity, initz, initDir = nav.pos.x, nav.pos.y, nav.pos.z, nav.pos.dir
- if nav.pos.z ~= 0 then
- nav.up(math.abs(nav.pos.z))
- end
- nav.goDir(2)
- if nav.pos.y ~= 0 then
- nav.forward(math.abs(nav.pos.y))
- end
- if nav.pos.x ~= 0 then
- if nav.pos.x < 0 then
- nav.goDir(1)
- nav.forward(math.abs(nav.pos.x))
- else
- nav.goDir(3)
- nav.forward(math.abs(nav.pos.x)
- end
- end
- functionCalled()
- nav.turnRight(2)
- nav.forward(inity)
- if initx/math.abs(initx) = -1 do
- nav.turnLeft(1)
- elseif initx/math.abs(initx) = 1 do
- nav.turnRight(1)
- end
- if initx ~= 0 then
- nav.forward(math.abs(initx))
- end
- nav.down(initz)
- nav.goDir(initDir)
- end
- function refuel()
- if turtle.getFuelLevel() < 2*(math.abs(nav.pos.z) + math.abs(nav.pos.y) + math.abs(math.pos.x) + 10) then
- if not turtle.refuel() then
- goBack(grabFuel)
- end
- end
- end
- function checkInv()
- if turtle.getItemCount(16) ~= 0 then
- goBack(dropOff)
- end
- end
- function grabFuel()
- turtle.suckUp(64)
- end
- function dropOff()
- for i=2, 16 do
- turtle.select(i)
- turtle.drop(64)
- end
- turtle.select(1)
- end
- function forward(x)
- for i = 1, x do
- nav.forward(1)
- refuel()
- checkInv()
- end
- end
Add Comment
Please, Sign In to add comment