Skip to content

Instantly share code, notes, and snippets.

@dillmo
Created February 22, 2014 15:22
Show Gist options
  • Save dillmo/9156485 to your computer and use it in GitHub Desktop.
Save dillmo/9156485 to your computer and use it in GitHub Desktop.
A ComputerCraft program to dig a lit 3x3 tunnel
-- 3x3 Tunnel by dillmo --
--[[
This program creates a 3x3 lit-up tunnel for as far as you want. To run
this program, place your turtle on the bottom row of the middle column of
your tunnel wall. Then, place torches in the turtle's first inventory
slot and cobblestone is the second slot. Before running the program, be
sure to configure the program to meet your needs.
--]]
-- Configuration --
local length = 61 -- The length of the tunnel
-- Function Definitions --
local function digVerticalLine()
while turtle.detect() do
turtle.dig()
end
turtle.forward()
while turtle.detectUp() do
turtle.digUp()
os.sleep(0.5)
end
turtle.digDown()
end
local function turnAround()
turtle.turnRight()
turtle.turnRight()
end
local function checkForHoles()
turtle.down()
if not turtle.detectDown() then
turtle.select(2)
turtle.placeDown()
end
turtle.up()
end
local function digIntoWall()
digVerticalLine()
checkForHoles()
turtle.turnLeft()
digVerticalLine()
checkForHoles()
turnAround()
turtle.forward()
digVerticalLine()
checkForHoles()
turnAround()
turtle.forward()
turtle.turnRight()
end
-- Program --
turtle.up()
for i=0, length - 1 do
digIntoWall()
if i % 5 == 0 then
turtle.select(1)
turtle.placeDown()
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment