dont require heading for point.closest

This commit is contained in:
kepler155c@gmail.com 2019-01-08 04:40:58 -05:00
parent f5294d4fce
commit b761b3429a
1 changed files with 6 additions and 1 deletions

View File

@ -177,7 +177,12 @@ function Point.closest(reference, pts)
local lm, lpt = math.huge
for _,pt in pairs(pts) do
local distance = Point.turtleDistance(reference, pt)
if distance < lm then
if not reference.heading then
if distance < lm then
lpt = pt
lm = distance
end
elseif distance < lm then
local _, _, m = Point.calculateMoves(reference, pt, distance)
if m < lm then
lpt = pt