diff --git a/mine/client.lua b/mine/client.lua index 0d685cf..522450b 100644 --- a/mine/client.lua +++ b/mine/client.lua @@ -566,7 +566,7 @@ function goToJob2(job) moveSafe(turtle.forward, turtle.inspect, noop) moveSafe(turtle.forward, turtle.inspect, noop) -- reset coords, descend - x, z = 0, 0 + x, z, direction = 0, 0, 0 moveSafe(turtle.down, turtle.inspectDown, noop) moveSafe(turtle.down, turtle.inspectDown, noop) moveSafe(turtle.down, turtle.inspectDown, noop) @@ -633,6 +633,36 @@ function goToUnloading() moveSafe(turtle.forward, turtle.inspect, noop) end +function reportDuty2() + updateState({ state = "Returning to report duty..." }) + moveSafe(turtle.up, turtle.inspectUp, noop) + moveSafe(turtle.up, turtle.inspectUp, noop) + moveSafe(turtle.up, turtle.inspectUp, noop) + moveSafe(turtle.up, turtle.inspectUp, noop) + for i = 1,11 do + moveSafeForward() + end + rednet.open("top") + id = turtlestate["job"] + fuelconsumed = turtlestate["fuel"] + rednet.broadcast(tostring(id), "jobs") + sleep(0.6) + --print("Proto: Sending fuel status") + rednet.broadcast(tostring(fuelconsumed), "fuel") + while true do + --print("Proto: Awaiting thanks") + updateState({ state = "Waiting for thanks..." }) + sender, message, proto = rednet.receive("jobcomplete", 2) + if message == "thanks" then + break + else + sleep(1) + end + end + --print("Proto: Received thanks") +end + + function turtleAI2() while true do local job = enqueueForJob2() @@ -641,9 +671,12 @@ function turtleAI2() digShaft() goToUnloading() unloadStuffs() - -- returnToQueue() - updateState({ state = "Fin" }) - break + reportDuty2() + moveSafe(turtle.down, turtle.inspectDown, turtle.digDown) + moveSafe(turtle.down, turtle.inspectDown, turtle.digDown) + moveSafe(turtle.down, turtle.inspectDown, turtle.digDown) + moveSafe(turtle.down, turtle.inspectDown, turtle.digDown) + turtle.turnLeft() end end -- turtleAI()