-- ################################
-- Boring by silktouch mining turtle
-- version 0.4
-- http://hevohevo.hatenablog.com/
-- This Program requires a SilkTouch Mining Turtle by "More Turtles" mod
-- "More Turtles" was created by Nokiyen.
-- http://www.computercraft.info/forums2/index.php?/topic/16465-mc164152-more-turtles-v112/
-- ########## config
MIN_FUEL_LEVEL = 64 * 6 + 64 + 10
FUEL_SLOT=16
CLOSE_HOLE_FLAG = true -- whether close a hole
LID_BLOCK_SLOT = 1
local args={...}
-- reverse CLOSE_HOLE_FLAG
if #args > 0 then CLOSE_HOLE_FLAG = not CLOSE_HOLE_FLAG end
-- ########## functions
local silkP = peripheral.wrap("right")
if silkP and silkP.digSilkTouch then
print("Boring with SilkTouch!")
turtle.dig_org = turtle.dig_org or turtle.dig
turtle.dig= silkP.digSilkTouch
turtle.digDown_org = turtle.digDown_org or turtle.digDown
turtle.digDown = silkP.digSilkTouchDown
end
function waitForEnoughItems(itemName, n, slot)
turtle.select(slot)
os.sleep(0.5)
while turtle.getItemCount(slot) < n do
if itemName then print(string.format("Insert %s into slot %d",itemName,slot)) end
os.pullEvent("turtle_inventory")
os.sleep(1)
end
end
function waitForEnoughFuel(minLevel, slot)
turtle.select(slot)
turtle.refuel()
while turtle.getFuelLevel() < minLevel do
print(string.format("Insert fuel-items into slot %d: %d/%d",slot, turtle.getFuelLevel(), minLevel))
os.pullEvent("turtle_inventory")
turtle.refuel()
os.sleep(1)
end
end
Count = 0
function revolve(depth)
for i=1, 4 do -- dig four sides
if turtle.dig() then Count=Count+1 end
turtle.turnRight()
end
if turtle.digDown() then Count=Count+1 end
if turtle.getFuelLevel() > depth + 10 then
return turtle.down() -- return true/false
else
return false -- if fuel shortage
end
end
function closeHole()
turtle.select(LID_BLOCK_SLOT)
turtle.down()
for i=1,4 do
turtle.place()
turtle.turnRight()
end
turtle.up()
turtle.placeDown()
end
function backToHome(n)
for i=1, n do -- back to home position.
turtle.up()
end
end
-- ########## main
waitForEnoughFuel(MIN_FUEL_LEVEL, FUEL_SLOT)
waitForEnoughItems("5 lid-blocks", 5, LID_BLOCK_SLOT)
local depth = 0
while revolve(depth) do
print("Depth: ",depth)
depth = depth +1
end
backToHome(depth)
if CLOSE_HOLE_FLAG then closeHole() end
print("Result: ",Count," blocks")
print("Current Fuel: ",turtle.getFuelLevel())