gghf icon

tryForwards

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

830 B

|

None

|

0 👍

/

0 👎

-- imports
local rS = require("returnSupplies")
local cl = require("collect")
local dR = require("doRefuel")
 
-- definition
local function tryForwards()
    if not dR.doRefuel() then
        print("Not enough Fuel")
        rS.returnSupplies()
    end
 
    while not turtle.forward() do
        if turtle.detect() then
            if turtle.dig() then
                if not cl.collect() then
                    rS.returnSupplies()
                end
            else
                return false
            end
        elseif turtle.attack() then
            if not cl.collect() then
                rS.returnSupplies()
            end
        else
            sleep(0.5)
        end
    end
 
    xPos = xPos + xDir
    zPos = zPos + zDir
    return true
end
 
-- export
return { tryForwards = tryForwards }

Comments