Advertisement
stolensteel

digroomv3

Mar 17th, 2013
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.31 KB | None | 0 0
  1. local args={...}
  2. local function gForward()
  3.   while not turtle.forward() do
  4.     turtle.dig()
  5.   end
  6. end
  7.  
  8. local function gUp()
  9.   while not turtle.up() do
  10.     print("GoingUp!")
  11.     turtle.digUp()
  12.   end
  13. end
  14.  
  15. local function digRow(length)
  16.   for i=2,length do
  17.     gForward()
  18.   end
  19. end
  20.  
  21. local function dig2Row(length)
  22.   turtle.digUp()
  23.   for i=2,length do
  24.     gForward()
  25.     turtle.digUp()
  26.   end
  27. end
  28.  
  29. local function digPlane(length,height)
  30.   local remainingHeight = height
  31.   local firstPass = true
  32.   while remainingHeight > 0 do
  33.     if not firstPass then
  34.       gUp()
  35.     else firstPass = false
  36.     end
  37.     if remainingHeight > 1 then
  38.       dig2Row(length)
  39.       gUp()
  40.       remainingHeight = remainingHeight - 2
  41.     else
  42.       digRow(length)
  43.       remainingHeight = remainingHeight - 1
  44.     end
  45.     turtle.turnLeft()
  46.     turtle.turnLeft()
  47.   end
  48.   for i = 1,height do
  49.     turtle.down()
  50.   end
  51.   if ((remainingHeight + 1) /2 ) % 2 == 1 then
  52.     digRow(length)
  53.     turtle.turnLeft()
  54.     turtle.turnLeft()
  55.   end
  56. end
  57.  
  58. local glength = tonumber(args[1])
  59. local gheight = tonumber(args[2])
  60. local gwidth = tonumber(args[3])
  61. for j = 1, gwidth do
  62.   print("Starting Plane "..j)
  63.   digPlane(glength,gheight)
  64.   if not (j == gwidth) then
  65.     turtle.turnLeft()
  66.     gForward()
  67.     turtle.turnRight()
  68.   end
  69. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement