diff --git a/AIDriver.lua b/AIDriver.lua index 2d519cdf9..a1509d483 100644 --- a/AIDriver.lua +++ b/AIDriver.lua @@ -544,10 +544,9 @@ function AIDriver:getRecordedSpeed() return speed end --- TODO: review this whole fillpoint/filltrigger mess. +-- TODO: review this whole fillpoint/filltrigger thing. function AIDriver:isNearFillPoint() - -- TODO: like above, we may have some better indication of this - return self.ppc:getCurrentWaypointIx() >= 1 and self.ppc:getCurrentWaypointIx() <= 3 or self.vehicle.cp.tipperLoadMode > 0 + return self.course:havePhysicallyPassedWaypoint(self.vehicle.cp.DirectionNode,#self.course.waypoints) and self.ppc:getCurrentWaypointIx() <= 3; end function AIDriver:getIsInFilltrigger() diff --git a/Waypoint.lua b/Waypoint.lua index e569edb67..b5b05a25d 100644 --- a/Waypoint.lua +++ b/Waypoint.lua @@ -393,6 +393,11 @@ function Course:getWaypointLocalPosition(node, ix) return dx, dz end +function Course:havePhysicallyPassedWaypoint(node, ix) + local _, dz = self:getWaypointLocalPosition(node, ix) + return dz < 0; +end + function Course:getWaypointAngleDeg(ix) return self.waypoints[math.min(#self.waypoints, ix)].angle end diff --git a/helpers.lua b/helpers.lua index b35daea01..188d69a69 100644 --- a/helpers.lua +++ b/helpers.lua @@ -320,6 +320,7 @@ function courseplay:fillTypesMatch(vehicle, fillTrigger, workTool,onlyCheckThisF end end if matchInThisUnit and selectedFillTypeIsNotInMyFillUnit then + courseplay.debugVehicle(19,vehicle,'fillTypesMatch(324): return true') return true; end end @@ -331,14 +332,19 @@ function courseplay:fillTypesMatch(vehicle, fillTrigger, workTool,onlyCheckThisF else courseplay.debugVehicle(19,vehicle,'fillTypesMatch: selectedFillType:%d',selectedFillType) if fillTrigger.source then - return fillTrigger.source.providedFillTypes[selectedFillType] or false; + local result = fillTrigger.source.providedFillTypes[selectedFillType] or false; + courseplay.debugVehicle(19,vehicle,'fillTypesMatch(337): return %s',tostring(result)) + return result; elseif fillTrigger.sourceObject ~= nil then local fillType = fillTrigger.sourceObject:getFillUnitFillType(1) - return fillType == selectedFillType; + local result = fillType == selectedFillType; + courseplay.debugVehicle(19,vehicle,'fillTypesMatch(342): return %s',tostring(result)) + return result; end end end end + courseplay.debugVehicle(19,vehicle,'fillTypesMatch(348): return false') return false; end; diff --git a/modDesc.xml b/modDesc.xml index 619831d55..4b05b6ac6 100644 --- a/modDesc.xml +++ b/modDesc.xml @@ -1,6 +1,6 @@ - 6.01.00152 + 6.01.00153 <br>CoursePlay SIX</br> diff --git a/toolManager.lua b/toolManager.lua index 887d4cb74..70e31b9e5 100644 --- a/toolManager.lua +++ b/toolManager.lua @@ -798,7 +798,7 @@ function courseplay:load_tippers(vehicle, allowedToDrive) if (vehicle.cp.tipperLoadMode == 0 or vehicle.cp.tipperLoadMode == 3) and not driveOn then --if vehicle.cp.ppc:haveJustPassedWaypoint(1) and currentTrailer.cp.currentSiloTrigger == nil then --vehicle.cp.ppc:haveJustPassedWaypoint(1) doesn't work here - if courseplay:havePhysicallyPassedWaypoint(vehicle,1) and currentTrailer.cp.currentSiloTrigger == nil then + if vehicle.cp.driver.course:havePhysicallyPassedWaypoint(vehicle.cp.DirectionNode, 1) and currentTrailer.cp.currentSiloTrigger == nil then --- We must be on an loading point at a field so we stop under wp1 and wait for trailer to be filled up vehicle.cp.tipperLoadMode = 2; elseif currentTrailer.cp.currentSiloTrigger then @@ -1892,10 +1892,3 @@ function courseplay:getAIMarkerWidth(object, logPrefix) end end end - -function courseplay:havePhysicallyPassedWaypoint(vehicle,index) - local cx, cz = vehicle.Waypoints[index].cx, vehicle.Waypoints[index].cz; --TODO Tommi convert this to the ppc, course, waypoint, no idea stuff - local _,dy,_ = getWorldTranslation(vehicle.cp.DirectionNode); - local _,_,tz = worldToLocal(vehicle.cp.DirectionNode,cx,dy,cz) - return tz < 0 -end \ No newline at end of file diff --git a/triggers.lua b/triggers.lua index 7c5f8733c..5b6e73acf 100644 --- a/triggers.lua +++ b/triggers.lua @@ -608,6 +608,7 @@ end; -- Adding easy access to SiloTrigger -------------------------------------------------- local SiloTrigger_TriggerCallback = function(self, triggerId, otherActorId, onEnter, onLeave, onStay, otherShapeId) + courseplay:debug(' SiloTrigger_TriggerCallback',2); local trailer = g_currentMission.nodeToObject[otherShapeId]; if trailer ~= nil then -- Make sure cp table is present in the trailer.