Advertisement
GauHelldragon

DigWall v1.0

Oct 21st, 2016
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.13 KB | None | 0 0
  1. local StoneSlot = 1
  2.  
  3. function refuel()
  4.     local slot = StoneSlot + 1
  5.     while ( turtle.getFuelLevel() < 100 and slot < 15 ) do
  6.         slot = slot + 1
  7.         turtle.select(slot)
  8.         turtle.refuel(10)
  9.     end
  10.     turtle.select(1)
  11. end
  12.  
  13. function tryForward()
  14.     refuel()
  15.     if (turtle.getFuelLevel() < 100 ) then
  16.         print "Ran out of fuel!"
  17.         os.exit()
  18.     end
  19.     return turtle.forward()
  20. end
  21.  
  22. function tryUp()
  23.     refuel()
  24.     if (turtle.getFuelLevel() < 100 ) then
  25.         print "Ran out of fuel!"
  26.         os.exit()
  27.     end
  28.     while ( not turtle.up() ) do
  29.         turtle.digUp()
  30.         os.sleep(1)
  31.     end
  32. end
  33.  
  34. function checkSpace()
  35.     if ( turtle.getItemCount(15) > 0 ) then
  36.         print "Ran out of space!"
  37.         os.exit()
  38.     end
  39. end
  40.  
  41. function checkSquare()
  42.     turtle.select(StoneSlot)
  43.     if ( turtle.compare() ) then return end
  44.     while ( turtle.detect() ) do
  45.         turtle.dig()
  46.     end
  47.     checkSpace()
  48. end
  49.  
  50. function digWall()
  51.     local hitEnd = false;
  52.    
  53.     repeat
  54.         checkSquare()
  55.         turtle.turnRight()
  56.         if ( tryForward()  ) then
  57.             turtle.turnLeft()
  58.         else
  59.             hitEnd = true;
  60.         end
  61.     until ( hitEnd )
  62. end
  63.  
  64. while ( turtle.detect() ) do
  65.     for wall=1,4 do
  66.         digWall()
  67.     end
  68.     tryUp()
  69. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement