Advertisement
fauxiss

strip

Apr 30th, 2013
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.67 KB | None | 0 0
  1. tunnels = 10
  2.  
  3. local tArgs = { ...}
  4. if #tArgs ~=1 then
  5.     print( "Usage: strip <length>" )
  6.     return
  7. end
  8.  
  9. local length = tonumber( tArgs[1] )
  10. if length < 1 then
  11.     print(  "Strip length must be positive" )
  12.     return
  13. end
  14.  
  15. local function refuel()
  16.     local fuelLevel = turtle.getFuelLevel()
  17.     if fuelLevel == "unlimited" or fuelLevel > 0 then
  18.         return
  19.     end
  20.  
  21.     local function tryRefuel()
  22.         for n=1,16 do
  23.             if turtle.getItemCount(n) > 0 then
  24.                 turtle.select(n)
  25.                 if turtle.refuel(1) then
  26.                     turtle.select(1)
  27.                     return true
  28.                 end
  29.             end
  30.         end
  31.         turtle.select(1)
  32.         return false
  33.     end
  34.  
  35.     if not tryRefuel() then
  36.         print( "Add more fuel to continue." )
  37.         while not tryRefuel() do
  38.             sleep(1)
  39.         end
  40.         print( "Resuming Tunnel." )
  41.     end
  42. end
  43.  
  44. local function detectup()
  45.     if turtle.detectUp() then
  46.         turtle.digUp()
  47.         sleep(0.4)
  48.     end
  49. end
  50.  
  51. local function strip()
  52.     refuel()
  53.     while not turtle.forward() do
  54.         while not turtle.dig() do
  55.             turtle.attack()
  56.         end
  57.     sleep(0.4)
  58.     detectup()
  59.     end
  60. end
  61.  
  62. local function otun()
  63.     strip()
  64.     strip()
  65.     detectup()
  66.     turtle.back()
  67.     turtle.back()
  68. end
  69.  
  70. local function turnaround()
  71.     turtle.turnRight()
  72.     strip()
  73.     strip()
  74.     strip()
  75.     otun()
  76.     turtle.turnRight()
  77. end
  78.  
  79. for n = 1, tunnels do
  80.     refuel()
  81.     for x = 1, length do
  82.         strip()
  83.     end
  84.     refuel()
  85.     turnaround()
  86.     x = 0
  87.     refuel()
  88.     for x = 1, length do
  89.         strip()
  90.     end
  91.     turtle.back()
  92.     detectup()
  93.     turtle.forward()
  94.     turtle.turnLeft()
  95.     turtle.forward()
  96.     turtle.forward()
  97.     turtle.forward()
  98.     turtle.turnLeft()
  99. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement