Advertisement
VaMinion

Ten by Ten dig

Jan 16th, 2014
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.64 KB | None | 0 0
  1. -- Digs a 10x10x3 room.
  2. -- Meant for quick excavation, not mass harvesting.
  3.  
  4. -- Use odd numbers for it to return to its starting point
  5. roomSize = 9
  6.  
  7. -- Tracks the turtle's position
  8. turtlePos = vector.new(0,0,0)
  9.  
  10. while turtlePos.y < roomSize do
  11.  -- Dig x column away from baseline
  12.  while turtlePos.x < roomSize do
  13.   while turtle.detect() do
  14.    turtle.dig()
  15.   end
  16.   -- Dig forward
  17.   while not turtle.forward() do
  18.    os.sleep(1)
  19.   end
  20.   turtlePos.x = turtlePos.x + 1
  21.   turtle.digUp()
  22.   turtle.digDown()
  23.  end
  24.  
  25.  -- Move to the right 1 Y column.
  26.  turtle.turnRight()
  27.  while turtle.detect() do
  28.   turtle.dig()
  29.  end
  30.  -- Move to the right 1
  31.  while not turtle.forward() do
  32.   os.sleep(1)
  33.  end
  34.  turtlePos.y = turtlePos.y + 1
  35.  turtle.digUp()
  36.  turtle.digDown()
  37.  
  38.  -- Turn again to continue digging.
  39.  turtle.turnRight()
  40.  
  41.  -- Dig x column back to baseline
  42.  while turtlePos.x > 1 do
  43.   while turtle.detect() do
  44.    turtle.dig()
  45.   end
  46.   -- Dig forward
  47.   while not turtle.forward() do
  48.    os.sleep(1)
  49.   end
  50.   turtlePos.x = turtlePos.x - 1
  51.   turtle.digUp()
  52.   turtle.digDown()
  53.  end
  54.  
  55.  if turtlePos.y < roomSize then
  56.   -- Move to the right 1 if we haven't finished the dig.
  57.   turtle.turnLeft()
  58.   while turtle.detect() do
  59.    turtle.dig()
  60.   end
  61.  
  62.   while not turtle.forward() do
  63.    os.sleep(1)
  64.   end
  65.   turtlePos.y = turtlePos.y + 1
  66.   turtle.digUp()
  67.   turtle.digDown()
  68.   turtle.turnLeft()
  69.  end
  70. end
  71.  
  72. -- Return home
  73. turtle.turnRight()
  74. while turtlePos.y > 0 do
  75.  while turtle.detect() do
  76.   turtle.dig()
  77.  end
  78.  -- Dig forward
  79.  while not turtle.forward() do
  80.   os.sleep(1)
  81.  end
  82.  turtlePos.y = turtlePos.y - 1
  83. end
  84.  
  85. turtle.turnRight()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement