Last active
December 12, 2015 04:58
-
-
Save rschulman/4718317 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
function isValuable() | |
if not turtle.detect() then return false end | |
for i=1,3 do | |
turtle.select(i) | |
if turtle.compare() then | |
print ("Same as "..i) | |
return false | |
end | |
end | |
return true | |
end | |
function dive() | |
local x, y, z = gps.locate(5) | |
local todive = z - 6 -- Only want to go down to z = 6 to avoid bedrock. | |
for depth=1,todive do | |
-- Move down, digging first if we have to | |
if turtle.detectDown() then | |
turtle.digDown() | |
end | |
turtle.down() | |
-- Check around us for things we might want to gather | |
for i=1,4 do | |
if isValuable() then turtle.dig() end | |
turtle.turnRight() | |
end | |
end | |
end | |
local tArgs = { ... } | |
local size | |
if tArgs[1] == nil then | |
size = 10 | |
else | |
size = tonumber(tArgs[1]) | |
end | |
rednet.open("right") | |
local startx, starty, startz = gps.locate(5) | |
for inner=1,size do | |
dive() | |
local newx, newy, newz = gps.locate(5) | |
local rise = startz - newz | |
for i=1,rise do | |
turtle.up() | |
end | |
turtle.turnRight() | |
turtle.forward() | |
turtle.forward() | |
turtle.forward() | |
turtle.forward() | |
turtle.turnLeft() | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment