I see a problem in CWaypointList:getNextWaypoint(_num). i'm not sure if it's the cause of the problem but maybe Administrator can have a look at it as I'm not sure I follow it.
Code: Select all
local hf_wpnum;
if( self.Direction == WPT_FORWARD ) then
hf_wpnum = self.CurrentWaypoint + _num;
if( hf_wpnum > #self.Waypoints ) then
self.CurrentWaypoint = hf_wpnum - #self.Waypoints;
end
else
self.CurrentWaypoint = self.CurrentWaypoint - _num;
if( self.CurrentWaypoint < 1 ) then
self.CurrentWaypoint = math.abs(#self.Waypoints - math.abs(self.CurrentWaypoint));
end
hf_wpnum = self.CurrentWaypoint;
end
I don't understand why the forward and reverse code are completely different. I would have expected the reverse to be the same as the forward but in reverse ie.
Code: Select all
hf_wpnum = self.CurrentWaypoint - _num;
if( hf_wpnum < 1 ) then
self.CurrentWaypoint = hf_wpnum + #self.Waypoints;
end
But, regardless, it looks like CurrentWaypoint gets set correctly.
hf_wpnum on the other-hand returns 2 different values. If forward, the hf_wpnum = self.CurrentWaypoint + _num which has the possibility of being more than #self.Waypoints but if reverse then hf_wpnum = the new self.CurrentWaypoint.
1 of these, I assume, is not the intended value.