mdc_tjc

MDC_Tunnel_Facing

Feb 14th, 2026 (edited)
3,950
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- This program creates a tunnel facing to facilitate mining via 5 x 5 tunnels
  2. -- Pastebin code = "LptADyfD"; Pastebin name is "MDC_Tunnel_Facing"
  3.  
  4. -- Place the turtle down on the right-forward end of the tunnel cut
  5. -- Place coal into Turtle slot #14 to assure adequate fueling
  6. -- Place netherite into Turtle slot #15 and #16 to assure adequate placement resources
  7. -- The program wants to know the options how many blocks you want to move forward before facing
  8. -- The options are RC - Right Corner; LC - Left Corner; CS - Center Section
  9. -- An example is RC 2; Right corner facing two blocks forward from turtle placement
  10.  
  11. local function mv_fwd() -- This function moves the turtle forward one block
  12.     if turtle.detect() then turtle.dig(); turtle.forward() else turtle.forward() end
  13.     end
  14.  
  15. local function mv_up() -- This function moves the turtle up one block
  16.     if turtle.detectUp() then turtle.digUp(); turtle.up() else turtle.up() end
  17.     end
  18.  
  19. local function mv_dwn() -- This function moves the turtle down one block
  20.     if turtle.detectDown() then turtle.digDown(); turtle.down() else turtle.down() end
  21.     end
  22.  
  23. local function sel_slot() -- This function selects the active slot for placing blocks
  24.     turtle.select(15)
  25.     if turtle.getItemCount() < 3 then turtle.select(16) end
  26.     end
  27.  
  28. local function place_fwd() -- This function places a block if none is present in front of the turtle
  29.     if not turtle.detect() then sel_slot(); turtle.place() end -- check forward and place
  30.     end
  31.  
  32. local function place_up()
  33.     if not turtle.detectUp() then sel_slot(); turtle.placeUp() end -- check up and place
  34.     end
  35.  
  36. local function place_dwn()
  37.     if not turtle.detectDown() then sel_slot(); turtle.placeDown() end -- check down and place
  38.     end
  39.  
  40. local function place_LC()
  41.     turtle.turnLeft() -- Position turtle for initial facing
  42.  
  43.     for iter3 = 1, desired_height do -- Face blocks up the left side
  44.         place_fwd(); mv_up()
  45.     end
  46.  
  47.     place_fwd(); turtle.turnRight(); place_fwd(); mv_dwn(); place_up()
  48.  
  49.     for iter4 = 2, desired_height do -- Face blocks down the left front column
  50.         place_fwd(); mv_dwn()
  51.     end
  52.  
  53.     place_fwd(); place_dwn()
  54.  
  55.     end
  56.  
  57. local function place_CS()
  58.  
  59.     place_dwn()
  60.  
  61.     for iter5 = 1, desired_height do -- Face blocks up the left-center
  62.         place_fwd(); mv_up()
  63.     end
  64.  
  65.     place_fwd(); mv_dwn(); place_fwd(); place_up();
  66.     turtle.turnRight(); mv_fwd(); turtle.turnLeft(); place_up()
  67.  
  68.     for iter6 = 2, desired_height do -- Face blocks down the center
  69.         place_fwd(); mv_dwn()
  70.     end
  71.  
  72.     place_fwd(); place_dwn(); turtle.turnRight(); mv_fwd(); turtle.turnLeft()
  73.  
  74.     for iter7 = 1, desired_height do -- Face blocks up the right-center
  75.         place_fwd(); mv_up()
  76.     end
  77.  
  78.     mv_dwn(); place_up(); for iter8 = 2, desired_height do mv_dwn() end
  79.  
  80.     place_dwn()
  81.  
  82.     end
  83.  
  84. local function place_RC()
  85.  
  86.     for iter8 = 1, desired_height do -- Face blocks up the right face
  87.         place_fwd(); mv_up()
  88.     end
  89.  
  90.     place_fwd(); turtle.turnRight(); place_fwd(); mv_dwn(); place_up()
  91.  
  92.     for iter9 = 2, desired_height do -- Face blocks down the right side
  93.         place_fwd(); mv_dwn()
  94.     end
  95.  
  96.     place_fwd(); place_dwn(); turtle.turnLeft()
  97.  
  98. end
  99.  
  100. if turtle.getFuelLevel() < 200 then
  101.     print( "Your fuel level is less than 200; refueling with 240." )
  102.     turtle.select(14); turtle.refuel(3)
  103.     end
  104.  
  105. text_input = { ... } -- Obtain the number of two-block sections desired
  106.  
  107. print ( "Checking Data Entered." )
  108.  
  109. if ( tonumber( text_input[2] ) < 0 ) then
  110.     print( "Error: You must respond with zero or a positive number." )
  111.     return
  112.     end
  113.  
  114. option = text_input[1]
  115. move_forward = tonumber( text_input[2] )
  116. desired_height = 5
  117. desired_width = 5
  118.  
  119. for iter1 = 1, move_forward do mv_fwd(); end
  120.  
  121. if option == "All" then
  122.  
  123.     place_LC()
  124.     turtle.turnRight(); mv_fwd(); turtle.turnLeft()
  125.  
  126.     place_CS()
  127.     turtle.turnRight(); mv_fwd(); turtle.turnLeft()
  128.  
  129.     place_RC()
  130.     turtle.turnLeft(); turtle.forward(); turtle.forward()
  131.     turtle.forward(); turtle.forward(); turtle.forward()
  132.     turtle.turnRight()
  133.  
  134. end
  135.  
  136. -- if option == "CS" then
  137. -- end
  138.  
  139. if option == "RC" then
  140.  
  141.     place_RC()
  142.  
  143. end
  144.  
  145. print("Program has completed successfully.")
Advertisement