Update client

This commit is contained in:
Dominic Zimmer 2020-07-07 17:49:23 +02:00
parent dec935be2d
commit 41894a5542

View File

@ -565,9 +565,6 @@ function goToJob2(job)
moveSafe(turtle.forward, turtle.inspect, noop)
moveSafe(turtle.forward, turtle.inspect, noop)
moveSafe(turtle.forward, turtle.inspect, noop)
moveSafe(turtle.forward, turtle.inspect, noop)
moveSafe(turtle.forward, turtle.inspect, noop)
moveSafe(turtle.forward, turtle.inspect, noop)
-- reset coords, descend
x, z = 0, 0
moveSafe(turtle.down, turtle.inspectDown, noop)
@ -583,6 +580,44 @@ function goToJob2(job)
--moveSafe(turtle.up, turtle.inspectUp, turtle.digUp)
end
function unloadStuffs()
updateState({ state = "Now unloading..." })
sleep(0.4)
for i = 1,16 do
turtle.select(i)
sleep(0.1)
turtle.drop()
end
end
function doRefuel2()
moveSafe(turtle.forward, turtle.inspect, noop)
moveSafe(turtle.forward, turtle.inspect, noop)
moveSafe(turtle.forward, turtle.inspect, noop)
curfuel = turtle.getFuelLevel()
targetfuel = 1500
if turtlestate["fuel"] != "" then
targetfuel = turtlestate["fuel"]
end
if curfuel > targetfuel then
return
end
updateState({ state = "Refueling... "..tostring(curfuel).." -> "..tostring(targetfuel) })
coalneeded = math.ceil((targetfuel - curfuel) / 80)
turtle.select(1)
while turtle.getFuelLevel() < targetfuel do
grabnow = math.min(coalneeded, 64)
if turtle.suckDown(grabnow) then
-- turtle can grab
coalneeded = coalneeded - grabnow
else
-- blabla error
updateState({ state = "Refueling... Error: Out of coal" })
sleep(5)
end
end
end
slots = { {7,-6}, {7, -7}, {7, -8}, {7,-5}, {7,-4} }
function goToUnloading()
updateState({ state = "Going to unload resources..." })
@ -595,17 +630,18 @@ function goToUnloading()
moveSafe(turtle.up, turtle.inspectUp, turtle.digUp)
faceDir(2)
moveSafe(turtle.forward, turtle.inspect, noop)
moveSafe(turtle.forward, turtle.inspect, noop)
end
function turtleAI2()
while true do
local job = enqueueForJob2()
doRefuel2()
goToJob2(job)
digShaft()
goToUnloading()
updateState({ state = "Now unloading..." })
unloadStuffs()
-- returnToQueue()
updateState({ state = "Fin" })
break
end
end