Orientation system changed.

This commit is contained in:
Harrison Deng 2021-05-07 20:32:35 -05:00
parent e3e7431d87
commit 366b3f6a0a

View File

@ -250,15 +250,17 @@ end
local function orient(v, forward, right) local function orient(v, forward, right)
print("Attempting to orient such that " .. tostring(v) .. " == " .. tostring(forward) .. ".") print("Attempting to orient such that " .. tostring(v) .. " == " .. tostring(forward) .. ".")
v = v:normalize() v = v / (v:length() * v:normalize())
if vectorEqual(v, forward) then if vectorEqual(v, forward) then
return true return true
elseif vectorEqual(v, right) then elseif vectorEqual(v, right) then
return attemptMoveRight() return attemptMoveRight()
elseif vectorEqual(v, -right) then elseif vectorEqual(v, -right) then
return attemptMoveLeft() return attemptMoveLeft()
else elseif vectorEqual(v, -forward) then
return attemptMoveRight() and attemptMoveRight() return attemptMoveRight() and attemptMoveRight()
else
sendLog(FAILED, "Improper axis given.");
end end
return false return false
end end
@ -368,7 +370,7 @@ local function moveBy(delta, forward, right)
end end
local function moveTo(dest) local function moveTo(dest)
dest = vector.new(math.floor(dest.x), math.floor(dest.y), math.floor(dest.z)) dest = dest:round()
sendLog(MOVETO, "Attempting to move by (" .. dest.x .. "," .. dest.y .. "," .. dest.z .. ") (x,y,z).") sendLog(MOVETO, "Attempting to move by (" .. dest.x .. "," .. dest.y .. "," .. dest.z .. ") (x,y,z).")
if position == nil or heading == nil then if position == nil or heading == nil then
sendLog(FAILED, "Position or heading is invalid.") sendLog(FAILED, "Position or heading is invalid.")
@ -436,7 +438,6 @@ local function quarry(x, y, z, forward, right, pattern)
for xDelta=1,math.abs(x) do for xDelta=1,math.abs(x) do
for zDelta=1,math.abs(z) do for zDelta=1,math.abs(z) do
local success = true; local success = true;
if (reverseTrip) then
orient(vector.new(0,0, -z), forward, right) orient(vector.new(0,0, -z), forward, right)
else else
orient(vector.new(0, 0, z), forward, right) orient(vector.new(0, 0, z), forward, right)