gghf icon

tryDown

gghf | PRO | 07/14/22 01:13:41 PM UTC (Edited) | 0 ⭐ | 667 👁️ | Never ⏰ | []
Lua |

900 B

|

None

|

0 👍

/

0 👎

-- imports
local rS = require("returnSupplies")
local cl = require("collect")
local dR = require("doRefuel")
 
-- definition
local function tryDown()
    if not dR.doRefuel() then
        print("Not enough Fuel")
        rS.returnSupplies()
    end
 
    while not turtle.down() do
        if turtle.detectDown() then
            if turtle.digDown() then
                if not cl.collect() then
                    rS.returnSupplies()
                end
            else
                return false
            end
        elseif turtle.attackDown() then
            if not cl.collect() then
                rS.returnSupplies()
            end
        else
            sleep(0.5)
        end
    end
 
    depth = depth + 1
    if math.fmod(depth, 10) == 0 then
        print("Descended " .. depth .. " metres.")
    end
 
    return true
end
 
-- export
return { tryDown = tryDown }

Comments