Skip to content

Instantly share code, notes, and snippets.

@CoderPuppy
Last active January 31, 2021 18:03
Show Gist options
  • Save CoderPuppy/af2730450cceadcd405b7b0b99303f12 to your computer and use it in GitHub Desktop.
Save CoderPuppy/af2730450cceadcd405b7b0b99303f12 to your computer and use it in GitHub Desktop.
ComputerCraft Tunneler
local fill_i
local fill_left = 0
local function place_fill(f)
if fill_left <= 0 then
local is = {}
for i = 1, 16 do
local d = turtle.getItemDetail(i)
if d then
is[d.name] = is[d.name] or i
end
end
local i = nil
or is['minecraft:cobblestone']
or is['minecraft:granite']
or is['minecraft:diorite']
or is['minecraft:andesite']
or is['minecraft:netherrack']
or is['minecraft:basalt']
or is['minecraft:blackstone']
assert(i, 'no fill')
fill_i = i
fill_left = turtle.getItemCount(i)
end
turtle.select(fill_i)
fill_left = fill_left - 1
return f()
end
local function move(move, dig)
while not move() do
dig()
end
end
local function tunnel_step()
assert(turtle.getFuelLevel() >= 11, 'not enough fuel for tunnel step')
move(turtle.forward, turtle.dig)
move(turtle.up, turtle.digUp)
place_fill(turtle.placeUp)
turtle.turnLeft()
move(turtle.forward, turtle.dig)
place_fill(turtle.placeUp)
place_fill(turtle.place)
move(turtle.down, turtle.digDown)
place_fill(turtle.place)
move(turtle.down, turtle.digDown)
place_fill(turtle.place)
place_fill(turtle.placeDown)
turtle.turnRight()
turtle.turnRight()
move(turtle.forward, turtle.dig)
place_fill(turtle.placeDown)
move(turtle.forward, turtle.dig)
place_fill(turtle.placeDown)
place_fill(turtle.place)
move(turtle.up, turtle.digUp)
place_fill(turtle.place)
move(turtle.up, turtle.digUp)
place_fill(turtle.place)
place_fill(turtle.placeUp)
turtle.back()
turtle.turnLeft()
turtle.down()
end
local function do_tunnel(n)
for i = 1, n do
tunnel_step()
end
end
do_tunnel(16)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment