Advertisement
Ubidibity

getPipe

Aug 4th, 2014
339
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.49 KB | None | 0 0
  1. -- Revision History
  2. -- 20140804 Initial draft, untested
  3. -- 20140811 update based on initial testing, turtle.compare() doesn't seem to recognize pipes but does recognize dirt/sand
  4. --          so loops will just have to detect that "something" is there that's not whatever surrounds the pipes...i.e.
  5. --          stone, slab, sand...(as those are the three main things I run pipe through), I'm in total pipe recovery mode
  6. --          at this point as tesseracts are now replacing the long pipe runs...
  7. -- Purpose/intro:
  8. -- pipes all over looking unsightly?  the goal of this is to follow a pipe and pick them back up.
  9. -- place pipe to reclaim in slot 1, position turtle directly in front of pipe to reclaim.
  10. -- turtle will start off picking up the pipe, once it doesn't detect a pipe it will attempt to turn to re-acquire the pipe
  11. -- in the event no pipe is to either side, above, or below it, it will stop.  (possibly eventually returning to the start)
  12.  
  13. -- select object to not reclaim (stone, iron tank wall, etc.)
  14. turtle.select(16)
  15.  
  16. -- while block in front, grab pipe, move forward
  17. -- position turtle in front of first pipe
  18.  
  19. while not turtle.compare() do
  20.   if not turtle.forward()
  21.     turtle.dig()
  22.     turtle.forward()
  23.   end
  24.  
  25.   -- after move, detect either a don't acquire block or nothing then look around
  26.   if turtle.compare() or not turtle.detect() then
  27.     turtle.turnRight()
  28.     -- No pipe to right, check to left.
  29.     if not turtle.compare() then
  30.       turtle.turnLeft()
  31.       turtle.turnLeft()
  32.       -- We know no pipe behind us, so pipe above?  If so, get it.
  33.       if not turtle.compare() then
  34.         if turtle.compareUp() then
  35.           while turtle.compareUp() do
  36.             turtle.digUp()
  37.             turtle.up()
  38.           end
  39.         end
  40.         -- if not, pipe below? If so, get it.
  41.         if turtle.compareDown() then
  42.           while turtle.compareDown() do
  43.             turtle.digDown()
  44.             turtle.down()
  45.           end
  46.         end
  47.         -- in case we moved up or down, attempt to re-acquire pipe 360 degrees.
  48.         if not turtle.compare() then
  49.           turtle.turnRight()
  50.         end
  51.         if not turtle.compare() then
  52.           turtle.turnRight()
  53.         end
  54.         if not turtle.compare() then
  55.           turtle.turnRight()
  56.         end
  57.         if not turtle.compare() then
  58.           turtle.turnRight()
  59.         end
  60.         -- here we should either be facing a pipe, or struck out 4 times, in which case it's time to end.
  61.       end
  62.     end
  63.   end
  64. end
  65. -- FIN
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement