This commit is contained in:
Dominic Zimmer 2020-07-07 14:12:35 +02:00
parent c2a8dfedaf
commit 4cfebcbdaa

View File

@ -83,7 +83,7 @@ function digSafe(inspectAction, digAction)
if status then
if block["name"]:lower():find("turtle") then
-- turtle in front of me. its free space
return true
break
else
digAction()
-- gravel may take time to fall.
@ -91,7 +91,7 @@ function digSafe(inspectAction, digAction)
end
else
-- No block in front of me. good
return true
break
end
end
end
@ -513,7 +513,7 @@ function faceDir(dir)
end
end
-- directions: 0, 1, 2, 3 -> x, z, -x, -z
function goToCoordXZ(targetX, targetZ, extraaction)
function goToCoordXZ2(targetX, targetZ, extraaction)
if targetX > x then
faceDir(0)
while (targetX > x) do
@ -548,7 +548,7 @@ function goToCoordXZ(targetX, targetZ, extraaction)
end
end
function goToJob(job)
function goToJob2(job)
jobX, jobZ = iTo2Dcoords(job) -- this does all the magic
updateState({ state = "Going on the job...", morestate = " Jobsite is at ("..tostring(jobX)..", "..tostring(jobZ)..")" })
-- move to hole
@ -564,25 +564,18 @@ function goToJob(job)
moveSafe(turtle.down, turtle.inspectDown, noop)
-- go to job
function extraaction()
repeat sleep(0.6) until (not digSafe(turtle.inspectUp, turtle.digUp()))
digSafe(turtle.inspectUp, turtle.digUp())
end
goToCoord(jobX, jobZ, extraaction)
goToCoordXZ2(jobX, jobZ, extraaction)
end
function turtleAI2()
while true do
local job = enqueueForJob2()
goToJob(job)
goToJob2(job)
-- returnToQueue()
break
end
end
function extraaction()
repeat sleep(0.6) until (not digSafe(turtle.inspectUp, turtle.digUp()))
end
-- turtleAI()
faceDir(3)
goToCoordXZ(4, 2, extraaction)
goToCoordXZ(0, 0, extraaction)
goToCoordXZ(4, 2, extraaction)
turtleAI2()