From 4cfebcbdaae9cce0c4bae45d29e9601f754c7479 Mon Sep 17 00:00:00 2001 From: Dominic Zimmer Date: Tue, 7 Jul 2020 14:12:35 +0200 Subject: [PATCH] update --- mine/client.lua | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/mine/client.lua b/mine/client.lua index 83afcfc..e74c9b6 100644 --- a/mine/client.lua +++ b/mine/client.lua @@ -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()