Changed heading calculation.

This commit is contained in:
Harrison Deng 2021-05-03 15:28:43 -05:00
parent 0396caf149
commit 22acaca89f

View File

@ -251,29 +251,27 @@ local function determineHeading()
sendLog(FAILED, "Could not move to get delta.") sendLog(FAILED, "Could not move to get delta.")
return return
end end
if x == nil then if position == nil then
sendLog(FAILED, "Could not locate.") sendLog(FAILED, "Could not locate.")
return return
end end
heading = position - oldPos local fDelta = position - oldPos
if not attemptMoveRight() then if not attemptMoveRight() then
sendLog(FAILED, "Unable to rotate right.") sendLog(FAILED, "Unable to rotate right.")
heading = nil
return return
end end
local oldPos = vector.new(position.x, position.y, position.z) local oldPos = vector.new(position.x, position.y, position.z)
if not attemptMoveForward() then if not attemptMoveForward() then
sendLog(FAILED, "Unable to move forward after rotation.") sendLog(FAILED, "Unable to move forward after rotation.")
heading = nil
return return
end end
if not attemptMoveLeft() then if not attemptMoveLeft() then
sendLog(FAILED, "Unable to rotate left.") sendLog(FAILED, "Unable to rotate left.")
heading = nil
return return
end end
heading = fDelta
rightAxis = position - oldPos rightAxis = position - oldPos
end end