Now stops on failure to "moveby".

This commit is contained in:
Harrison Deng 2021-05-03 18:18:53 -05:00
parent bcf30e259d
commit 6f94e81ca1

View File

@ -332,25 +332,37 @@ local function moveBy(delta, forward, right)
sendLog(MOVEBY, "Moving on x axis by: " .. delta.x)
orient(vector.new(delta.x, 0, 0):normalize(), forward, right)
for x=1,math.abs(delta.x) do
attemptMoveForward()
if not attemptMoveForward() then
sendLog(FAILED, "Unable to move forward.")
return
end
end
end
if delta.z ~= 0 then
sendLog(MOVEBY, "Moving on z axis by: " .. delta.z)
orient(vector.new(0, 0, delta.z):normalize(), forward, right)
for z=1,math.abs(delta.z) do
attemptMoveForward()
if not attemptMoveForward() then
sendLog(FAILED, "Unable to move forward.")
return
end
end
end
if delta.y > 0 then
sendLog(MOVEBY, "Moving on y axis by: " .. delta.y)
for y=1,delta.y do
attemptMoveUp()
if not attemptMoveUp() then
sendLog(FAILED, "Unable to move up.")
return
end
end
elseif delta.y < 0 then
sendLog(MOVEBY, "Moving on y axis by: " .. delta.y)
for y=1,math.abs(delta.y) do
attemptMoveDown()
if not attemptMoveDown() then
sendLog(FAILED, "Unable to move down.")
return
end
end
end
end