Created
August 14, 2015 12:38
-
-
Save popkirby/b11d9928158f423a9d52 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
os.loadAPI("apis/myTurtle") | |
local forward = myTurtle.forward | |
local back = myTurtle.back | |
local up = myTurtle.up | |
local down = myTurtle.down | |
local left = myTurtle.left | |
local right = myTurtle.right | |
local t = myTurtle | |
function digTunnel(len) | |
local i = 1 | |
for i = 1, len do | |
t.dig(forward) | |
t.move(forward) | |
t.dig(left) | |
t.dig(up) | |
t.move(up) | |
t.dig(left) | |
t.move(down) | |
end | |
end | |
function digBranch(len) | |
local i = 1 | |
local dug = 0 | |
repeat | |
t.dig(forward) | |
if t.move(forward) then | |
dug = dug + 1 | |
end | |
t.dig(up) | |
until dug == len | |
turtle.placeUp() | |
t.turn(back) | |
for i = 1, len do | |
t.move(forward) | |
end | |
end | |
print("start mining...") | |
turtle.select(1) | |
while 1 do | |
local torches = turtle.getItemCount() | |
if torches < 3 then | |
break | |
end | |
digTunnel(3) | |
t.turn(back) | |
turtle.place() | |
t.turn(left) | |
digBranch(8) | |
t.move(forward) | |
digBranch(8) | |
t.move(forward) | |
t.turn(left) | |
end | |
print("mining finished!") | |
-- vim: ft=lua |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment