Guest User

quarry.lua

a guest
Jul 18th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.21 KB | None | 0 0
  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
  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
  20.         nav.turnRight()
  21.     end
  22.     if nav.pos.y ~= 0 then
  23.         nav.forward(math.abs(nav.pos.y))
  24.     end
  25.     if nav.pos.x ~= 0 then
  26.         if nav.pos.x < 0 then
  27.             while nav.pos.dir ~= 1 do
  28.                 nav.turnRight()
  29.             end
  30.             nav.forward(math.abs(nav.pos.x))
  31.         else
  32.             while nav.pos.dir ~= 3 do
  33.                 nav.turnRight()    
  34.             end
  35.             nav.forward(math.abs(nav.pos.x)
  36.         end
  37.     end
  38.     functionCalled()
  39.    
  40. end
  41.  
  42. function refuel()
  43.     if turtle.getFuelLevel() < 200 then
  44.         if not turtle.refuel() then
  45.             goBack(grabFuel)
  46.         end
  47.     end
  48. end
  49.  
  50. function forward(x)
  51.     for i = 1, x do
  52.         nav.forward(1)
  53.         if checkFuel() == then
  54.         end
  55.         if checkInv == then
  56.         end
  57.     end
Advertisement
Add Comment
Please, Sign In to add comment