Guest User

quarryDigger

a guest
Dec 12th, 2012
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.23 KB | None | 0 0
  1. local x, y, z
  2. local width, length, depth = 0, 0, 0
  3. local xPos, yPos, zPos = 0, 0, 0
  4. function digLevel(w, l, d)
  5. x=0
  6. y=0
  7. z=0
  8.     turtle.down()
  9.     while z < tonumber(d) do
  10.         while x < tonumber(w) do
  11.    if y > 0 then
  12.             while y< tonumber(l) do
  13.                 digOn()
  14.                 y = y + 1
  15.             end
  16.    else
  17.      while y>0 do
  18.        digOn()
  19.        y=y-1
  20.      end
  21.    end
  22.             newRow(y)
  23.             x=x+1
  24.         end
  25.         goDown(x,y)
  26.         x=0
  27.         y=0
  28.     end
  29.    end
  30.  
  31. function newRow(yy)
  32.     turtle.digDown()
  33.     if yy>1 then
  34.         turtle.turnRight()
  35.     else
  36.         turtle.turnLeft()
  37.     end
  38.     turtle.forward()
  39.     turtle.digDown()
  40.     if yy>1 then
  41.         turtle.turnRight()
  42.     else
  43.     turtle.turnLeft()
  44.     end
  45. end
  46.  
  47. function digOn()
  48.     turtle.digDown()
  49.     turtle.forward()
  50. end
  51.  
  52. function goDown(xx,yy)
  53.     if yy>1 then
  54.         turtle.turnRight()
  55.         while yy > 0 do
  56.             turtle.forward()
  57.             yy=yy-1
  58.         end
  59.         turtle.turnLeft()
  60.     else
  61.         turtle.turnRight()
  62.     end
  63.    
  64.     while xx > 0 do
  65.         turtle.forward()
  66.         xx = xx - 1
  67.     end
  68.     turtle.down()
  69.     turtle.digDown()
  70.     turtle.turnRight()
  71. end
  72.  
  73. term.write("What is the width of your quarry? ")
  74. width = read()
  75. term.write("What is the length of your quarry? ")
  76. length = read()
  77. term.write("How deep? ")
  78. depth = read()
  79. digLevel(width, length, depth)
Advertisement
Add Comment
Please, Sign In to add comment