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