Advertisement
OldDragon2A

Make Air Shaft (maybe smarter)

Dec 15th, 2012
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Will create an air shaft to the surface
  2.  
  3. function checkfuel()
  4.   if turtle.getFuelLevel() == 0 then
  5.     print "Out of Fuel"
  6.     exit()
  7.   end
  8. end
  9.  
  10. function findCeiling()
  11.   while not turtle.detectUp() do
  12.     turtle.up()
  13.     checkfuel()
  14.     sleep(0)
  15.   end
  16. end
  17.  
  18. function digShaft()
  19.   while turtle.detectUp() do
  20.     if turtle.digUp() then turtle.up() end
  21.     checkfuel()
  22.     sleep(0)
  23.   end
  24. end
  25.  
  26. function park()
  27.   local turns = 0
  28.   while turtle.detect() do
  29.     turtle.turnLeft()
  30.     turns = turns + 1
  31.     if turns % 4 == 0 then
  32.       if turtle.detectUp() then turtle.digUp() end
  33.       turtle.up()
  34.       checkfuel()
  35.     end
  36.     sleep(0)
  37.   end
  38.   turtle.forward()
  39. end
  40.  
  41. findCeiling()
  42. digShaft()
  43. park()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement