Compare commits

..

No commits in common. "8f396e50275b5789cc260061ab6bde75533f9edb" and "b3f659b2b7fc48b295503b985fc502275af3fd62" have entirely different histories.

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
break return true
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
break return true
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 goToCoordXZ2(targetX, targetZ, extraaction) function goToCoordXZ(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 goToCoordXZ2(targetX, targetZ, extraaction)
end end
end end
function goToJob2(job) function goToJob(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,18 +564,25 @@ function goToJob2(job)
moveSafe(turtle.down, turtle.inspectDown, noop) moveSafe(turtle.down, turtle.inspectDown, noop)
-- go to job -- go to job
function extraaction() function extraaction()
digSafe(turtle.inspectUp, turtle.digUp()) repeat sleep(0.6) until (not digSafe(turtle.inspectUp, turtle.digUp()))
end end
goToCoordXZ2(jobX, jobZ, extraaction) goToCoord(jobX, jobZ, extraaction)
end end
function turtleAI2() function turtleAI2()
while true do while true do
local job = enqueueForJob2() local job = enqueueForJob2()
goToJob2(job) goToJob(job)
-- returnToQueue() -- returnToQueue()
break break
end end
end end
turtleAI2() 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)