The code for the function is here:
Spoiler
local function saveProgress(extras) --Session persistence
exclusions = { modem = true, }
if doBackup then
local toWrite = ""
for a,b in pairs(getfenv(1)) do
if not exclusions[a] then
--print(a ," ", b, " ", type(B)/>) --Debug
if type(B)/> == "string" then b = "\""..b.."\"" end
if type(B)/> == "table" then b = textutils.serialize(B)/> end
if type(B)/> ~= "function" then
toWrite = toWrite..a.." = "..tostring(B)/>.."\n"
end
end
end
toWrite = toWrite.."doCheckFuel = false\n" --It has already used fuel, so calculation unnesesary
local file
repeat
file = fs.open(saveFile,"w")
until file
file.write(toWrite) --=================Too long without yielding here===========================
if type(extras) == "table" then
for a, b in pairs(extras) do
file.write(a.." = "..tostring(B)/>)
end
end
file.close()
end
end
Spoiler
function mine(doDigDown, doDigUp, outOfPath,doCheckInv) -- Basic Move Forward
if doCheckInv == nil then doCheckInv = true end
if doDigDown == nil then doDigDown = true end
if doDigUp == nil then doDigUp = true end
if outOfPath == nil then outOfPath = false end
if inverted then
doDigUp, doDigDown = doDigDown, doDigUp --Just Switch the two if inverted
end
if doRefuel and checkFuel() <= fuelTable[fuelSafety]/2 then
for i=1, 16 do
if turtle.getItemCount(i) > 0 then
turtle.select(i)
if checkFuel() < 200 + fuelTable[fuelSafety] then
turtle.refuel()
end
end
end
end
local count = 0
while not forward(not outOfPath) do
sleep(0) --Calls coroutine.yield to prevent errors
count = count + 1
if not dig() then
attack()
end
if count > 10 then
attack()
sleep(0.2)
end
if count > 50 then
if turtle.getFuelLevel() == 0 then --Don't worry about inf fuel because I modified this function
saveProgress({doCheckFuel = true})
error("No more fuel",0)
elseif yPos > (startY-7) then --If it is near bedrock
bedrock()
else --Otherwise just sleep for a bit to avoid sheeps
sleep(1)
end
end
end
checkSanity() --Not kidding... This is necessary
saveProgress(tab) --============================================RIGHT HERE====================
if doDigUp then
while turtle.detectUp() do
sleep(0) --Calls coroutine.yield
if not dig(true,turtle.digUp) then --This needs to be an absolute, because we are switching doDigUp/Down
attackUp()
count = count + 1
end
if count > 50 and yPos > (startY-7) then --Same deal with bedrock as above
bedrock()
end
end
end
if doDigDown then
dig(true,turtle.digDown) --This needs to be absolute as well
end
percent = math.ceil(moved/moveVolume*100)
updateDisplay()
isInPath = (not outOfPath) --For rednet
if doCheckInv and careAboutResources then
if moved%invCheckFreq == 0 then
if isFull(16-keepOpen) then dropOff() end
end; end
if rednetEnabled then biometrics() end
end
--Insanity Checking
function checkSanity()
if isInPath and not (facing == 0 or facing == 2) and #events == 0 then --If mining and not facing proper direction and not in a turn
turnTo(0)
rowCheck = "right"
end
if xPos < 0 or xPos > x or zPos < 0 or zPos > z or yPos < 0 then
saveProgress()
print("Oops. Detected that quarry was outside of predefined boundaries.")
print("Please go to my forum thread and report this with a short description of what happened")
print("If you could also run \"pastebin put Civil_Quarry_Restore\" and give me that code it would be great")
error("",0)
end
end
Any help would be appreciated. Thank you for reading.