Advertisement
Zapp

3x3 tunnel with torches

Mar 24th, 2013
1,661
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.55 KB | None | 1 0
  1. -- 3x3 Tunnel digger script for ComputerCraft turtle by Scott 'Satscape' Hather - www.satscape.info
  2. -- Place the turtle at the front left of where you want the 3x3xinfinte tunnel (and facing it)
  3. -- Place a chest directly behind it
  4. -- Place torches in the bottom right slot (one stack will last 640 metres)
  5. -- Place coal/lava etc in first slot
  6. -- It will empty itself into the chest at regular intervals and embed torches in the tunnel walls! (only works with latest CC - requires modifying to work with turtles with 9 slots)
  7.  
  8. if turtle.getItemCount(16) == 0 then
  9.     print("Place some torches in the last slot");
  10.     os.sleep(10);
  11.     os.reboot();
  12. end
  13.  
  14. if turtle.getFuelLevel()==0 then
  15.     turtle.select(1);
  16.     local ok=turtle.refuel();
  17.     if not ok then
  18.         print("Place some fuel into first slot");
  19.         os.sleep(10);
  20.         os.reboot();
  21.     end
  22. end
  23.  
  24. distanceFromChest=0;
  25. distanceWere=0;
  26.  
  27. function digAndMove()
  28.     while (turtle.detect()) do
  29.         turtle.dig(); os.sleep(1);
  30.     end
  31.     turtle.forward();
  32. end
  33.  
  34. function digAndMoveUp()
  35.     while (turtle.detectUp()) do
  36.         turtle.digUp(); os.sleep(1);
  37.     end
  38.     turtle.up();
  39. end
  40.  
  41. while (turtle.getItemCount(16) >0) do
  42.     print("Diggy Diggy hole, got "..turtle.getFuelLevel().." fuel left.");
  43.     distanceFromChest=distanceFromChest + 1;
  44.     digAndMove(); -- bottom left
  45.     turtle.turnRight();
  46.     digAndMove(); -- bottom centre
  47.     digAndMove(); -- bottom right
  48.     turtle.turnLeft();
  49.     digAndMoveUp(); -- centre right
  50.     turtle.turnLeft();
  51.     digAndMove(); -- centre centre
  52.     digAndMove(); -- centre left
  53.    
  54.     if distanceFromChest % 10 == 1 then
  55.         turtle.dig();
  56.         turtle.select(16);
  57.         turtle.place(); -- place the torch embedded in tunnel
  58.     end
  59.  
  60.     turtle.turnRight();
  61.     digAndMoveUp(); -- top left
  62.     turtle.turnRight();
  63.     digAndMove();  -- top centre
  64.     digAndMove(); -- top right
  65.  
  66.     turtle.turnLeft();
  67.     turtle.turnLeft();
  68.     turtle.forward(); turtle.forward();
  69.     turtle.turnRight();
  70.     turtle.down();
  71.     turtle.down();
  72.    
  73.     if distanceFromChest % 50 ==0 then  -- time to empty our stuff
  74.         distanceWere=distanceFromChest;
  75.         turtle.turnLeft(); turtle.turnLeft();
  76.         while distanceFromChest > 0 do
  77.             turtle.forward();
  78.             distanceFromChest = distanceFromChest - 1;
  79.         end
  80.         os.sleep(1);
  81.         for slot=1, 15, 1 do
  82.             turtle.select(slot);
  83.             turtle.drop();
  84.         end
  85.         os.sleep(1);
  86.         turtle.turnLeft(); turtle.turnLeft();
  87.         while distanceWere > 0 do
  88.             turtle.forward();
  89.             distanceWere = distanceWere - 1;
  90.             distanceFromChest = distanceFromChest + 1;
  91.         end
  92.     end
  93. end
  94. print("Ending tunnel2 script");
  95. os.sleep(10);
  96. os.reboot(); -- reboots until you place torches in last slot
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement