Haruchai

ender

Jan 26th, 2015
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.76 KB | None | 0 0
  1. args={...}
  2. x=args[1]
  3. y=0
  4. j=1
  5. turn="Right"
  6. canMoveForward=function()
  7.         while not turtle.forward() do
  8.                 if turtle.detect() then
  9.                         turtle.dig()
  10.                 else
  11.                         turtle.attack()
  12.                 end
  13.         end
  14.         j = j + 1
  15. end
  16. canMoveDown=function()
  17.         while not turtle.down() do
  18.                 if turtle.detectDown() then
  19.                         turtle.digDown()
  20.                 else
  21.                         turtle.attackDown()
  22.                 end
  23.         end
  24. end
  25. digLevel=function()
  26.         for i=1, x do
  27.                 while j<tonumber(x) do
  28.                         canMoveForward()
  29.                 end
  30.                 if i<tonumber(x)
  31.                 then
  32.                         if turn=="Left"
  33.                         then
  34.                                 turn="Right"
  35.                                 turtle.turnLeft()
  36.                                 canMoveForward()
  37.                                 turtle.turnLeft()
  38.                         else
  39.                                 turn="Left"
  40.                                 turtle.turnRight()
  41.                                 canMoveForward()
  42.                                 turtle.turnRight()
  43.                         end
  44.                 else
  45.                         if turn=="Left"
  46.                         then
  47.                                 turtle.turnRight()
  48.                                 turtle.turnRight()
  49.                         else
  50.                                 turtle.turnLeft()
  51.                                 turtle.turnLeft()
  52.                         end
  53.                 end
  54.                 j=1
  55.         end
  56. end
  57. print("Mining " .. x .. " x " .. x .. " mine")
  58. while not turtle.detectDown() or turtle.digDown() do
  59.         digLevel()
  60.         turn="Right"
  61.         if turtle.getItemCount(16)>0
  62.         then
  63.                 turtle.select(1)
  64.                 turtle.placeUp()
  65.                 for i=3, 16 do
  66.                         turtle.select(i)
  67.                         turtle.dropUp()
  68.                 end
  69.                 turtle.select(1)
  70.                 turtle.digUp()
  71.         end
  72.         if turtle.getFuelLevel()< (x * x)
  73.         then
  74.                 turtle.select(2)
  75.                 turtle.placeUp()
  76.                 turtle.select(16)
  77.                 turtle.refuel()
  78.                 turtle.suckUp(1,1)
  79.                 turtle.select(2)
  80.                 turtle.digUp()
  81.         end
  82.         canMoveDown()
  83.         y=y+1
  84. end
  85. digLevel()
  86. for i=1, y do
  87.         turtle.up()
  88. end
  89. turtle.select(1)
  90.         turtle.placeUp()
  91.         for i=3, 16 do
  92.                 turtle.select(i)
  93.                 turtle.dropUp()
  94.         end
  95. turtle.select(1)
  96. turtle.digUp()
  97. print( x .. " x " .. x .. " mine complete")
Advertisement
Add Comment
Please, Sign In to add comment