local t = turtle
blacklist = {}
local function blacklisted (what)
for _, b in ipairs(blacklist) do
if string.match(what, b) then
return true
end
end
return false
end
-- FIXME
local function digAround ()
return false
end
function hook ()
if t.digsafe then return false end
t.digsafe = {}
for i, d in pairs({
["inspectUp"] = "digUp",
["inspectDown"] = "digDown"
}) do
t.digsafe[d] = t[d]
t[d] = function ()
local x, y = t[i]()
if not x then return false end
if blacklisted(y["name"]) then
return false
end
return t.digsafe[d]()
end
end
t.digsafe.dig = t.dig
t.dig = function ()
local x, y = t.inspect()
if not x then return false end
if blacklisted(y["name"]) then
return digAround()
end
return t.digsafe.dig()
end
return true
end