From 1bdc32081892ea8a1aaec52adba70b038595f215 Mon Sep 17 00:00:00 2001 From: Harrison Deng Date: Wed, 5 May 2021 19:23:58 -0500 Subject: [PATCH] Modified moveto in preparation for circumnavigation. --- mineleader.lua | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/mineleader.lua b/mineleader.lua index d2ea94b..1757cb0 100644 --- a/mineleader.lua +++ b/mineleader.lua @@ -269,8 +269,7 @@ local function attemptStartTask(name, f, ...) end task = {name=name, func=f, args=arg} taskArgs = arg -end - +end -- Actions @@ -366,7 +365,7 @@ local function moveBy(delta, forward, right) end end -local function moveTo(dest, range) +local function moveTo(dest) sendLog(MOVETO, "Attempting to move by (" .. dest.x .. "," .. dest.y .. "," .. dest.z .. ") (x,y,z).") if position == nil or heading == nil then sendLog(FAILED, "Position or heading is invalid.") @@ -376,8 +375,8 @@ local function moveTo(dest, range) local oldPos = nil while not vectorEqual(dest, position) do if oldPos ~= nil and vectorEqual(oldPos, position) then - sendLog(FAILED, "Cannot proceed to due obstacle.") - return + sendLog(FAILED, "Cannot proceed to due obstacle. XYZ being blocked: " .. xBlocked .. "," .. yBlocked .. "," .. zBlocked) + break end oldPos = vector.new(position.x, position.y, position.z); if position.x ~= dest.x then @@ -385,13 +384,13 @@ local function moveTo(dest, range) sendLog(FAILED, "Unable to orient for X axis.") return end - attemptMoveForward() + xblocked = attemptMoveForward() end if position.y ~= dest.y then if dest.y - position.y > 0 then - attemptMoveUp() + yBlocked = attemptMoveUp() else - attemptMoveDown() + yBlocked = attemptMoveDown() end end if position.z ~= dest.z then @@ -399,7 +398,7 @@ local function moveTo(dest, range) sendLog(FAILED, "Unable to orient for Z axis.") return end - attemptMoveForward() + zBlocked = attemptMoveForward() end end end