Advertisement
Guest User

tun

a guest
Dec 15th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.45 KB | None | 0 0
  1. function countblocks()
  2.     return 8
  3. end
  4.  
  5. function Swap()
  6.     turtle.dig()
  7.     turtle.place()
  8. end
  9.  
  10. function SwapDown()
  11.     turtle.digDown()
  12.     turtle.placeDown()
  13. end        
  14.  
  15. function SwapUp()
  16.     turtle.digUp()
  17.     turtle.placeUp()
  18. end
  19.  
  20. function refill_blocks()
  21.     turtle.select(16)
  22.     turtle.place()
  23.    
  24.     for i=1,14 do
  25.         if turtle.getItemCount(i) == 0 then
  26.             while turtle.getItemSpace(i) ~= 0 do
  27.                 turtle.select(i)
  28.                 turtle.suck()
  29.             end
  30.         end
  31.     end
  32.     turtle.select(16)
  33.     turtle.dig()
  34. end
  35.  
  36. function TunnelIter()
  37.     turtle.dig()
  38.     turtle.forward()
  39.     turtle.turnRight()
  40.     Swap()
  41.     SwapDown()
  42.     turtle.turnLeft()
  43.     turtle.turnLeft()
  44.     turtle.forward()
  45.     Swap()
  46.     SwapDown()
  47.     turtle.digUp()
  48.     turtle.up()
  49.     Swap()
  50.     SwapUp()
  51.     turtle.turnRight()
  52.     turtle.turnRight()
  53.     turtle.dig()
  54.     turtle.forward()
  55.     Swap()
  56.     SwapUp()
  57.     turtle.down()
  58.     turtle.turnLeft()
  59. end
  60.  
  61. function main( args )
  62.     print(args)
  63.     local tunlen = tonumber(args[1])
  64.     local i = 0
  65.     while i < tunlen do
  66.         if turtle.getFuelLevel < 10 then
  67.             if countblocks() >= 8 then
  68.                 TunnelIter()
  69.                 i=i+1
  70.             else
  71.                 refill_blocks()
  72.                 turtle.select(1)
  73.             end
  74.         else
  75.             turtle.refuel(15)
  76.         end
  77.     end
  78. end
  79.  
  80. arg = {...}
  81. main(arg)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement