|
os.loadAPI("/lib/apis/bore/utils.lua") |
|
os.loadAPI("/lib/apis/bore/constants.lua") |
|
|
|
term.clear() |
|
utils.printCenter("Welcome to the tunnel bore 9000") |
|
utils.printCenter("dstn.to", true, true) |
|
|
|
utils.refuel() |
|
|
|
term.clear() |
|
|
|
local currentItteration = 0 |
|
|
|
local totalTorches = 0 |
|
for i = 1, 16 do |
|
local item = turtle.getItemDetail(i) |
|
if item and item.name == "minecraft:torch" then |
|
totalTorches = totalTorches + turtle.getItemCount(i) |
|
end |
|
end |
|
|
|
if totalTorches >= 1 then |
|
utils.printTop("Torch mode is enabled as there is "..totalTorches.." in the inventory") |
|
os.sleep(1.5) |
|
term.clear() |
|
end |
|
|
|
utils.printTop("Tunnel distance") |
|
utils.printTop("How far we goin?", false) |
|
local distanceEntry = read() |
|
local distance = tonumber(distanceEntry) |
|
|
|
term.clear() |
|
|
|
if distance == nil then |
|
utils.printTop("Exiting...") |
|
utils.printTop() |
|
utils.printTop("Invalid value, enter a distance in meters (blocks)", false) |
|
error() |
|
end |
|
|
|
local torchFirst = true |
|
local torchBlockGap = 7 |
|
|
|
if totalTorches >= 1 then |
|
utils.printTop("Options") |
|
utils.printTop("Torch on first wall? ([y]/n)", false) |
|
torchFirst = read() |
|
if torchFirst == nil then torchFirst = true end |
|
|
|
if torchFirst ~= "y" and torchFirst ~= "n" then |
|
utils.printTop("Invalid value, enter 'y' or 'n'", false) |
|
error() |
|
end |
|
|
|
utils.printTop("Torch block gap [7]", false) |
|
local torchBlockGap = read() |
|
if torchBlockGap == "" then torchBlockGap = 7 end |
|
torchBlockGap = tonumber(torchBlockGap) |
|
|
|
if torchBlockGap == nil then |
|
utils.printTop("Invalid value, enter a torch block gap in meters (blocks)", false) |
|
error() |
|
end |
|
|
|
term.clear() |
|
end |
|
|
|
local defaultPosition = "bottom" |
|
if not turtle.detectDown() then defaultPosition = "middle" end |
|
|
|
utils.printTop("3x3 Start position") |
|
utils.printTop("Middle or Bottom? ["..defaultPosition.."]:", false) |
|
local middleOrBottom = read() |
|
|
|
term.clear() |
|
|
|
if string.lower(middleOrBottom) == "middle" then |
|
middleOrBottom = "middle" |
|
elseif string.lower(middleOrBottom) == "bottom" then |
|
middleOrBottom = "bottom" |
|
else |
|
if middleOrBottom == "" then |
|
middleOrBottom = defaultPosition |
|
else |
|
utils.printTop("Exiting...") |
|
utils.printTop() |
|
utils.printTop("Invalid option, valid options [middle, bottom]", false) |
|
error() |
|
end |
|
end |
|
|
|
utils.printCenter("Creating a "..distance.."m 3x3 tunnel") |
|
|
|
if middleOrBottom == "bottom" then turtle.up() end |
|
|
|
function doDigging() |
|
currentItteration = currentItteration + 1 |
|
|
|
turtle.dig() |
|
turtle.forward() |
|
turtle.digUp() |
|
turtle.digDown() |
|
turtle.turnLeft() |
|
turtle.dig() |
|
turtle.forward() |
|
turtle.digUp() |
|
turtle.digDown() |
|
turtle.back() |
|
|
|
if (currentItteration == 1 and torchFirst) or utils.mod(currentItteration, torchBlockGap) then utils.placeTorch() end |
|
|
|
turtle.turnRight() |
|
turtle.turnRight() |
|
turtle.dig() |
|
turtle.forward() |
|
turtle.digUp() |
|
turtle.digDown() |
|
turtle.back() |
|
|
|
if (currentItteration == 1 and torchFirst) or utils.mod(currentItteration, torchBlockGap) then utils.placeTorch() end |
|
|
|
turtle.turnLeft() |
|
end |
|
|
|
for i = 1, distance do |
|
local currentFuel = turtle.getFuelLevel() |
|
|
|
if currentFuel-constants.fuelNeeded < 0 then |
|
local refueled = utils.refuel() |
|
|
|
if refueled == false then |
|
print("Sorry but there is not enough fuel to break down the next wall, please input some coal") |
|
exit() |
|
end |
|
end |
|
|
|
doDigging() |
|
end |