It's a bit hard to explain. It has to do with how the homing actually works.
It's based off whether or not link is within range along either the x or y axis. for 8dir it should change direction only when lined up every 45 degrees. do to the way the lined_up function was written. Because it was always abs(lx-x)-abs(ly-y)<=range. but if link is farther on the y axis then the x axis but not lined up 8way (45 degrees again) then it doesn't matter because it results in a negative number. Similarily it will always result in a positive if link is far enough on the x axis and very close on the y axis to it's relative point.