Grauly

CC_Turtle_Tunnel_cstm

Apr 11th, 2021 (edited)
887
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local fuelSlot = 1
  2. local floorWireID = "chisel:factory"
  3. local floorWires = {
  4.     2;
  5. }
  6. local floorSideID = "chisel:technicalnew"
  7. local floorSide = {
  8.     3;
  9.     4;
  10. }
  11. local floorMainID = "chisel:laboratory"
  12. local floorMain = {
  13.     5;
  14.     6;
  15. }
  16. local wallsID = "chisel:laboratory"
  17. local walls = {
  18.     9;
  19.     10;
  20.     11;
  21.     12;
  22.     13;
  23.     14;
  24.     15;
  25.     16;
  26. }
  27.  
  28. local IECNET = false
  29. -- end of config
  30. local args = {...}
  31.  
  32. function refuel()
  33.     if(turtle.getFuelLevel() < 5) then
  34.         turtle.select(fuelSlot)
  35.         if(turtle.refuel(1) == false) then
  36.             error("out of fuel")
  37.         end
  38.     end
  39. end
  40.  
  41. --digs the block infront
  42. function digForward()
  43.     while(turtle.dig()) do
  44.     end
  45. end
  46.  
  47. --digs the block below
  48. function digDown()
  49.     while(turtle.digDown()) do
  50.     end
  51. end
  52.  
  53. --digs the block above
  54. function digUp()
  55.     while(turtle.digUp()) do
  56.     end
  57. end
  58.  
  59. function placeWalls()
  60.     for i=1, #walls do
  61.         turtle.select(walls[i])
  62.         if(turtle.getItemCount() > 0) then
  63.             if(turtle.getItemDetail().name == wallsID) then
  64.                 while(not turtle.place()) do
  65.                     digForward()
  66.                 end
  67.                 return true
  68.             end
  69.         end
  70.     end
  71.     return false
  72. end
  73.  
  74. function placeWallsUp()
  75.     for i=1, #walls do
  76.         turtle.select(walls[i])
  77.         if(turtle.getItemCount() > 0) then
  78.             if(turtle.getItemDetail().name == wallsID) then
  79.                 while(not turtle.placeUp()) do
  80.                     digDown()
  81.                 end
  82.                 return true
  83.             end
  84.         end
  85.     end
  86.     return false
  87. end
  88.  
  89. function placeFloorWire()
  90.     for i=1, #floorWires do
  91.         turtle.select(floorWires[i])
  92.         if(turtle.getItemCount() > 0) then
  93.             if(turtle.getItemDetail().name == floorWireID) then
  94.                 while(not turtle.placeDown()) do
  95.                     digDown()
  96.                 end
  97.                 return true
  98.             end
  99.         end
  100.     end
  101.     return false
  102. end
  103.  
  104. function placeFloorSide()
  105.     for i=1, #floorSide do
  106.         turtle.select(floorSide[i])
  107.         if(turtle.getItemCount() > 0) then
  108.             if(turtle.getItemDetail().name == floorSideID) then
  109.                 while(not turtle.placeDown()) do
  110.                     digDown()
  111.                 end
  112.                 return true
  113.             end
  114.         end
  115.     end
  116.     return false
  117. end
  118.  
  119. function placeFloorMain()
  120.     for i=1, #floorMain do
  121.         turtle.select(floorMain[i])
  122.         if(turtle.getItemCount() > 0) then
  123.             if(turtle.getItemDetail().name == floorMainID) then
  124.                 while(not turtle.placeDown()) do
  125.                     digDown()
  126.                 end
  127.                 return true
  128.             end
  129.         end
  130.     end
  131.     return false
  132. end
  133.  
  134. function goForward()
  135.     digForward()
  136.     turtle.forward()
  137.     digUp()
  138.     digDown()
  139.     refuel()
  140. end
  141.  
  142. function turn()
  143.     turtle.turnRight()
  144.     turtle.turnRight()
  145. end
  146.  
  147. function move(dist)
  148.     for i=2,dist,1 do
  149.         turtle.forward()
  150.         refuel()
  151.     end
  152. end
  153.  
  154. function floorPlaceOneDirection()
  155.     goForward()
  156.     placeFloorWire()
  157.     goForward()
  158.     placeFloorSide()
  159.     goForward()
  160.     placeFloorMain()
  161.     goForward()
  162.     placeFloorMain()
  163.     digForward()
  164. end
  165.  
  166. function tunnel()
  167.     --assumes the turtle is in the middle on the floor
  168.     refuel()
  169.     digForward()
  170.     turtle.forward()
  171.     digUp()
  172.     digDown()
  173.     placeFloorWire()
  174.     turtle.turnRight()
  175.    
  176.     floorPlaceOneDirection()
  177.     placeWalls()
  178.    
  179.     turn()
  180.     move(5)
  181.    
  182.     floorPlaceOneDirection()
  183.     placeWalls()
  184.    
  185.     refuel()
  186.    
  187.     for i=1,3,1 do
  188.         digUp()
  189.         turtle.up()
  190.         digForward()
  191.         placeWalls()
  192.     end
  193.     digUp()
  194.     placeWallsUp()
  195.    
  196.     turn()
  197.    
  198.     refuel()
  199.     for i=2,9,1 do
  200.         goForward()
  201.         placeWallsUp()
  202.     end
  203.     digForward()
  204.     placeWalls()
  205.    
  206.     for i=1,2,1 do
  207.         digDown()
  208.         turtle.down()
  209.         digForward()
  210.         placeWalls()
  211.     end
  212.    
  213.     refuel()
  214.     turtle.down()
  215.    
  216.     turn()
  217.     refuel()
  218.     move(5)
  219.    
  220.     turtle.turnRight()
  221. end
  222. local iterations = 1
  223. if(not(args[1] == nil)) then
  224.     iterations = args[1]
  225. end
  226. print("starting")
  227. for i=1,iterations,1 do
  228.     tunnel()
  229. end
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×