diff --git a/scripts/ai/turns/AITurn.lua b/scripts/ai/turns/AITurn.lua index 67545ccc8..628931520 100644 --- a/scripts/ai/turns/AITurn.lua +++ b/scripts/ai/turns/AITurn.lua @@ -577,8 +577,10 @@ function CourseTurn:endTurn(dt) end function CourseTurn:updateTurnProgress() - local progress = self.turnCourse:getCurrentWaypointIx() / #self.turnCourse - self.vehicle:raiseAIEvent("onAIFieldWorkerTurnProgress", "onAIImplementTurnProgress", progress, self.turnContext:isLeftTurn()) + if self.turnCourse then + local progress = self.turnCourse:getCurrentWaypointIx() / self.turnCourse:getNumberOfWaypoints() + self.vehicle:raiseAIEvent("onAIFieldWorkerTurnProgress", "onAIImplementTurnProgress", progress, self.turnContext:isLeftTurn()) + end end function CourseTurn:onWaypointChange(ix)