Advertisement
fauxiss

StripMine Adventures

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