AgentTadpole

Strip Miner

Nov 25th, 2013
3,638
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.63 KB | None | 0 0
  1. local args = {...}
  2.  
  3. local stripLength = 32
  4.  
  5. if not #args == 1 then
  6.   print("Usage: smine <mines>")
  7.   return
  8. end
  9.  
  10. function strip()
  11.   for i=1,stripLength do
  12.     checkFuel()
  13.     checkInv()
  14.     while not turtle.forward() do turtle.dig() end
  15.     while turtle.detectUp() do
  16.       turtle.digUp()
  17.       sleep(0.2)
  18.     end
  19.     while turtle.detectDown() do
  20.       turtle.digDown()
  21.       sleep(0.2)
  22.     end
  23.    
  24.     if i%8 == 0 then
  25.       turtle.select(16)
  26.       while not turtle.forward() do turtle.dig() end
  27.       while turtle.detectUp() do
  28.         turtle.digUp()
  29.         sleep(0.2)
  30.       end
  31.       if not turtle.back() then
  32.         turtle.turnLeft()
  33.         turtle.turnLeft()
  34.         while not turtle.forward do turtle.dig() end
  35.         turtle.turnLeft()
  36.         turtle.turnLeft()
  37.       end
  38.       turtle.placeUp()
  39.       turtle.select(1)
  40.     end
  41.   end
  42.  
  43.   turtle.turnLeft()
  44.   turtle.turnLeft()
  45.  
  46.   for i=1,stripLength do
  47.     while not turtle.forward() do turtle.dig() end
  48.   end
  49. end
  50.  
  51. function checkFuel()
  52.   if turtle.getFuelLevel() <= 64 then
  53.     print("Error: Low fuel")
  54.     for i=1,14 do
  55.       turtle.select(i)
  56.       turtle.refuel()
  57.     end
  58.   end
  59. end
  60.  
  61. function checkInv()
  62.   isFull = true
  63.  
  64.   for i=1,14 do
  65.     if turtle.getItemCount(i) == 0 then
  66.       isFull = false
  67.     end
  68.   end
  69.  
  70.   if isFull == true then
  71.     turtle.select(15)
  72.     while not turtle.placeDown() do turtle.digDown() end
  73.     for i=1,14 do
  74.       turtle.select(i)
  75.       turtle.dropDown()
  76.     end
  77.   end
  78. end
  79.  
  80. for x=1,args[1] do
  81.   turtle.turnLeft()
  82.   strip()
  83.   strip()
  84.   turtle.turnRight()
  85.   for y=1,3 do turtle.forward() end
  86. end
Advertisement
Add Comment
Please, Sign In to add comment