Advertisement
Gorzoid

gDig

Oct 30th, 2015
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local config = {}
  2. config.itemFuel = 80
  3. config.fuelSlot = 16
  4.  
  5. local data = {}
  6. data.distance = 0
  7. data.fuelBuff = 0
  8.  
  9. function reloadFuelBuff()
  10.   data.fuelBuff = turtle.getItemCount()*config.itemFuel
  11. end
  12.  
  13. function checkInv()
  14.   return turtle.getItemCount(16) > 0
  15. end
  16.  
  17. function checkFuel()
  18.   if(turtle.getFuelLevel() < 10) then
  19.     turtle.refuel(1)
  20.     reloadFuelBuff()
  21.   end
  22.   return turtle.getFuelLevel()+data.fuelBuff > data.distance+5
  23. end
  24.  
  25. function goForward(i)
  26.   if(not turtle.forward()) then
  27.     if(t>=5) then error("Immovable Object") end
  28.     turtle.dig()
  29.     goForward(i and i+1 or 1)
  30.   end
  31. end
  32.  
  33. function finish()
  34.   turtle.turnLeft()
  35.   turtle.turnLeft()
  36.   for i = 1,data.distance do
  37.     goForward()
  38.   end
  39. end
  40.  
  41. function digLoop()
  42.     goForward()
  43.     turtle.digDown()
  44.     turtle.digUp()
  45. end
  46.  
  47. function init()
  48.     reloadFuelBuff()
  49.     while checkFuel() and checkInv() do
  50.         digLoop()
  51.     end
  52.     finish()
  53. end
  54. print("Ready? Put fuel in the active slot")
  55. read()
  56. init()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement