Advertisement
Nova38

Dig conputerCraft

May 26th, 2020
999
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.32 KB | None | 0 0
  1.  
  2. --[[
  3.       This program creates a 3x3 lit-up tunnel for as far as you want. To run
  4.       this program, place your turtle on the bottom row of the middle column of
  5.       your tunnel wall. Then, place torches in the turtle's first inventory
  6.       slot and cobblestone is the second slot. Before running the program, be
  7.       sure to configure the program to meet your needs.
  8. --]]
  9.  
  10. -- Configuration --
  11. local length = 61 -- The length of the tunnel
  12.  
  13. -- Function Definitions --
  14. local function digVerticalLine()
  15.   while turtle.detect() do
  16.     turtle.dig()
  17.   end
  18.   turtle.forward()
  19.   while turtle.detectUp() do
  20.     turtle.digUp()
  21.     os.sleep(0.5)
  22.   end
  23.   turtle.digDown()
  24. end
  25.  
  26. local function turnAround()
  27.   turtle.turnRight()
  28.   turtle.turnRight()
  29. end
  30.  
  31. local function checkForHoles()
  32.   turtle.down()
  33.   if not turtle.detectDown() then
  34.     turtle.select(2)
  35.     turtle.placeDown()
  36.   end
  37.   turtle.up()
  38. end
  39.  
  40. local function digIntoWall()
  41.   digVerticalLine()
  42.   checkForHoles()
  43.   turtle.turnLeft()
  44.   digVerticalLine()
  45.   checkForHoles()
  46.   turnAround()
  47.   turtle.forward()
  48.   digVerticalLine()
  49.   checkForHoles()
  50.   turnAround()
  51.   turtle.forward()
  52.   turtle.turnRight()
  53. end
  54.  
  55. -- Program --
  56. turtle.up()
  57. for i=0, length - 1 do
  58.   digIntoWall()
  59.   if i % 5 == 0 then
  60.     turtle.select(1)
  61.     turtle.placeDown()
  62.   end
  63. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement