Advertisement
stolensteel

digroomv4

Mar 17th, 2013
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.  
  10.   --print("GoingUp!")
  11.   while not turtle.up() do
  12.     turtle.digUp()
  13.   end
  14. end
  15.  
  16. local function digRow(length)
  17.   for i=2,length do
  18.     gForward()
  19.   end
  20. end
  21.  
  22. local function dig2Row(length)
  23.   turtle.digUp()
  24.   for i=2,length do
  25.     gForward()
  26.     turtle.digUp()
  27.   end
  28. end
  29.  
  30. local function placeChest()
  31.   turtle.select(1)
  32.   print("Placing the goods!")
  33.   while not turtle.place() do
  34.     turtle.dig()
  35.   end
  36.   for i=2,18 do
  37.     turtle.select(i)
  38.     turtle.drop()
  39.   end
  40.  
  41.  
  42. local function digPlane(length,height)
  43.   local remainingHeight = height
  44.   local firstPass = true
  45.   while remainingHeight > 0 do
  46.     if not firstPass then
  47.       gUp()
  48.     else firstPass = false
  49.     end
  50.     if remainingHeight > 1 then
  51.       dig2Row(length)
  52.       gUp()
  53.       remainingHeight = remainingHeight - 2
  54.     else
  55.       digRow(length)
  56.       remainingHeight = remainingHeight - 1
  57.     end
  58.     turtle.turnLeft()
  59.     turtle.turnLeft()
  60.   end
  61.   for i = 2,height do
  62.     turtle.down()
  63.   end
  64.   if ((remainingHeight + 1) /2 ) % 2 == 1 then
  65.     digRow(length)
  66.     turtle.turnLeft()
  67.     turtle.turnLeft()
  68.   end
  69.   placeChest()
  70. end
  71.  
  72. local glength = tonumber(args[1])
  73. local gheight = tonumber(args[2])
  74. local gwidth = tonumber(args[3])
  75. for j = 1, gwidth do
  76.   print("Starting Plane "..j)
  77.   digPlane(glength,gheight)
  78.   if not (j == gwidth) then
  79.     turtle.turnLeft()
  80.     gForward()
  81.     turtle.turnRight()
  82.   end
  83. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement