Advertisement
mDiyo

rectangledig

Dec 1st, 2013
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.32 KB | None | 0 0
  1. --This code digs a rectangular area
  2. function storecontents(height)
  3.   for y = 1, height, 1 do
  4.     turtle.up()
  5.   end
  6.   for slot = 1, 16, 1 do
  7.     turtle.select(slot)
  8.   turtle.drop()
  9.   end
  10.   for y = 1, height, 1 do
  11.     turtle.down()
  12.   end
  13. end
  14.  
  15. local tArgs = {...}
  16. xPos = tArgs[1]
  17. yPos = tArgs[2]
  18. zPos = tArgs[3]
  19. if xPos == nil or yPos == nil or zPos == nil then
  20.   print("Usage: digArea <x> <y> <z>")
  21.   return -1
  22. end
  23. xPos = tonumber(xPos)
  24. yPos = tonumber(yPos)
  25. zPos = tonumber(zPos)
  26. print("Moving...")
  27.  
  28. x = 0
  29. y = 0
  30. z = 0
  31. flip = false
  32. while true do
  33.   x = x + 1
  34.   turtle.dig()
  35.   turtle.forward()
  36.   if x >= xPos-1 then
  37.     x = 0
  38.     z = z + 1
  39.     if (z >= zPos) then
  40.       z = 0
  41.       y = y + 1
  42.       if y >= yPos then
  43.         storecontents(y-1)
  44.         break
  45.       else
  46.         if y % 2 == 0 then
  47.         storecontents(y-1)
  48.       end
  49.       turtle.turnLeft()
  50.       turtle.turnLeft()
  51.       turtle.digDown()
  52.       turtle.down()
  53.       flip = not flip
  54.     end
  55.   else
  56.     if flip then
  57.       turtle.turnLeft()
  58.       turtle.dig()
  59.       turtle.forward()
  60.       turtle.turnLeft()
  61.     else
  62.       turtle.turnRight()
  63.       turtle.dig()
  64.       turtle.forward()
  65.       turtle.turnRight()
  66.     end
  67.   end
  68.   flip = not flip
  69.   end
  70. end
  71.  
  72. yPos = yPos - 1
  73. while yPos > 0 do
  74.   yPos = yPos - 1
  75.   turtle.up()
  76. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement