Finalize(?) client

This commit is contained in:
Dominic Zimmer 2020-07-07 18:21:56 +02:00
parent 51287b6d03
commit c08d6e973b

View File

@ -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()