From 366b3f6a0af37bf491a1f8c5f63c35dd6ff37d5d Mon Sep 17 00:00:00 2001 From: Harrison Deng Date: Fri, 7 May 2021 20:32:35 -0500 Subject: [PATCH] Orientation system changed. --- mineleader.lua | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/mineleader.lua b/mineleader.lua index af9e602..b34ff5f 100644 --- a/mineleader.lua +++ b/mineleader.lua @@ -250,15 +250,17 @@ end local function orient(v, forward, right) print("Attempting to orient such that " .. tostring(v) .. " == " .. tostring(forward) .. ".") - v = v:normalize() + v = v / (v:length() * v:normalize()) if vectorEqual(v, forward) then return true elseif vectorEqual(v, right) then return attemptMoveRight() elseif vectorEqual(v, -right) then return attemptMoveLeft() - else + elseif vectorEqual(v, -forward) then return attemptMoveRight() and attemptMoveRight() + else + sendLog(FAILED, "Improper axis given."); end return false end @@ -368,7 +370,7 @@ local function moveBy(delta, forward, right) end 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).") if position == nil or heading == nil then sendLog(FAILED, "Position or heading is invalid.") @@ -436,8 +438,7 @@ local function quarry(x, y, z, forward, right, pattern) for xDelta=1,math.abs(x) do for zDelta=1,math.abs(z) do local success = true; - if (reverseTrip) then - orient(vector.new(0,0,-z), forward, right) + orient(vector.new(0,0, -z), forward, right) else orient(vector.new(0, 0, z), forward, right) end