Advertisement
moomoomoo309

netherTunnel

May 1st, 2015
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.74 KB | None | 0 0
  1. args={...}
  2. local iterations=tonumber(args[1])
  3. if #args==0 then
  4.   repeat
  5.     io.write("Distance: ")
  6.     iterations=tonumber(io.read())
  7.     print("")
  8.   until iterations~=nil and iterations>0
  9. end
  10.  
  11. local function refill()
  12.   if turtle.getItemCount(1)==0 then
  13.     for i=2,16 do
  14.       if turtle.getItemCount(i)~=0 then
  15.         turtle.select(i)
  16.         turtle.transferTo(1)
  17.         turtle.select(1)
  18.       end
  19.     end
  20.   end
  21. end
  22.  
  23. oldTurtle={}
  24. oldTurtle.place=turtle.place
  25. oldTurtle.placeUp=turtle.placeUp
  26. oldTurtle.placeDown=turtle.placeDown
  27. oldTurtle.dig=turtle.dig
  28. oldTurtle.digUp=turtle.digUp
  29. oldTurtle.digDown=turtle.digDown
  30. turtle.place=function()
  31.   refill()
  32.   while not oldTurtle.place() and not turtle.detect() do
  33.       turtle.attack()
  34.   end
  35. end
  36. turtle.placeUp=function()
  37.   refill()
  38.   while not oldTurtle.placeUp() and not turtle.detectUp() do
  39.     turtle.attackUp()
  40.   end
  41. end
  42. turtle.placeDown=function()
  43.   refill()
  44.   while not oldTurtle.placeDown() and not turtle.detectDown() do
  45.     turtle.attackDown()
  46.   end
  47. end
  48. turtle.dig=function()
  49.   while turtle.detect() and not oldTurtle.dig() do
  50.     turtle.attack()
  51.   end
  52. end
  53. turtle.digUp=function()
  54.   while turtle.detectUp() and not oldTurtle.digUp() do
  55.     turtle.attackUp()
  56.   end
  57. end
  58. turtle.digDown=function()
  59.   while turtle.detectDown() and not oldTurtle.digDown() do
  60.     turtle.attackDown()
  61.   end
  62. end
  63. for i=1,iterations do
  64.   turtle.digDown()
  65.   turtle.placeDown()
  66.   turtle.digUp()
  67.   turtle.turnLeft()
  68.   turtle.dig()
  69.   turtle.place()
  70.   turtle.up()
  71.   turtle.dig()
  72.   turtle.place()
  73.   turtle.turnRight()
  74.   turtle.digUp()
  75.   turtle.placeUp()
  76.   turtle.turnRight()
  77.   turtle.dig()
  78.   turtle.place()
  79.   turtle.down()
  80.   turtle.dig()
  81.   turtle.place()
  82.   turtle.turnLeft()
  83. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement