This commit is contained in:
Dominic Zimmer 2020-07-06 19:18:11 +02:00
parent 86aa002444
commit eb535fa029

View File

@ -77,6 +77,22 @@ function iTo2Dcoords(j)
end
end
function digSafe(inspectAction, digAction)
while true do
local status, block = inspectAction()
if status then
if block["name"]:lower():find("turtle") then
-- turtle in front of me. lets wait for it to move
return true
else
digAction()
end
else
return true
end
end
end
-- move safely into the direction, not hurting other turtles, but freeing the path if needed.
function moveSafe(moveAction, inspectAction, digAction)
while true do
@ -529,6 +545,9 @@ function goToCoordXZ(targetX, targetZ, extraaction)
end
end
function digSafe(inspectAction, digAction)
end
function goToJob(job)
jobX, jobZ = iTo2Dcoords(job) -- this does all the magic
updateState({ state = "Going on the job...", morestate = " Jobsite is at ("..tostring(jobX)..", "..tostring(jobZ)..")" })
@ -559,8 +578,11 @@ function turtleAI2()
end
end
function extraaction()
repeat sleep(0.6) until (not digSafe(turtle.inspectUp, turtle.digUp()))
end
-- turtleAI()
faceDir(3)
goToCoordXZ(4, 2, noop)
goToCoordXZ(0, 0, noop)
goToCoordXZ(4, 2, noop)
goToCoordXZ(4, 2, extraaction)
goToCoordXZ(0, 0, extraaction)
goToCoordXZ(4, 2, extraaction)