diff --git a/AIDriverUtil.lua b/AIDriverUtil.lua index 94b597c52..0e27d7695 100644 --- a/AIDriverUtil.lua +++ b/AIDriverUtil.lua @@ -290,6 +290,8 @@ function AIDriverUtil.isAllFolded(object) return true end +--- These functions only find directly attached implements/trailer to the vehicle. +--- Implements of others for example a shovel attached to a front loader are not detected. function AIDriverUtil.hasAIImplementWithSpecialization(vehicle, specialization) return AIDriverUtil.getAIImplementWithSpecialization(vehicle, specialization) ~= nil end diff --git a/BunkerSiloAIDriver.lua b/BunkerSiloAIDriver.lua index ea1aaed96..95fe07bfc 100644 --- a/BunkerSiloAIDriver.lua +++ b/BunkerSiloAIDriver.lua @@ -336,7 +336,7 @@ function BunkerSiloAIDriver:setupDriveOutOfSiloCourse() local closestColumn = self.bunkerSiloManager:getClosestColumnToNode(self:getDirectionNode(),1) local course,ix = self:getDriveOutOfSiloCourse(closestColumn) self:siloDebug("Starting drive out of silo course at: %d",ix) - self:startCourse(course,ix) + self:startCourse(course,course:getNumberOfWaypoints()) self:changeSiloState(self.states.DRIVING_OUT_OF_SILO) end diff --git a/BunkerSiloLoaderAIDriver.lua b/BunkerSiloLoaderAIDriver.lua index 8cbbce2fe..b2af9c992 100644 --- a/BunkerSiloLoaderAIDriver.lua +++ b/BunkerSiloLoaderAIDriver.lua @@ -28,7 +28,7 @@ function BunkerSiloLoaderAIDriver:init(vehicle) self.dischargeObject = AIDriverUtil.getImplementWithSpecialization(self.vehicle,Dischargeable) or self.vehicle self.dischargeSpec = self.dischargeObject.spec_dischargeable self.currentDischargeNode = self.dischargeObject:getCurrentDischargeNode() - + self.mode = courseplay.MODE_SHOVEL_FILL_AND_EMPTY end function BunkerSiloLoaderAIDriver:setHudContent() diff --git a/CompactingAIDriver.lua b/CompactingAIDriver.lua index 9c3bb53c2..b2a0ede0b 100644 --- a/CompactingAIDriver.lua +++ b/CompactingAIDriver.lua @@ -30,6 +30,7 @@ function CompactingAIDriver:init(vehicle) self:initStates(CompactingAIDriver.myStates) self.debugChannel = 10 self.compactingState = self.states.NOTHING + self.mode = courseplay.MODE_BUNKERSILO_COMPACTER end function CompactingAIDriver:setHudContent() diff --git a/ShovelAIDriver.lua b/ShovelAIDriver.lua index c0f9c1dcf..822c7b89e 100644 --- a/ShovelAIDriver.lua +++ b/ShovelAIDriver.lua @@ -63,6 +63,7 @@ function ShovelAIDriver:init(vehicle) self.shovelState = self.states.DRIVING_UNLOADING_COURSE self.shovelDebugChannel = courseplay.DBG_MODE_9 self.transitionCourseOffset = 20 + self.mode = courseplay.MODE_SHOVEL_FILL_AND_EMPTY end function ShovelAIDriver:setHudContent() @@ -71,14 +72,13 @@ function ShovelAIDriver:setHudContent() end function ShovelAIDriver:start(startingPoint) - self.shovel = AIDriverUtil.getImplementWithSpecialization(self.vehicle,Shovel) or self.vehicle - self.currentDischargeNode = self.shovel:getCurrentDischargeNode() - + self:findShovelRecursive(self.vehicle) if not self.shovel then self:error("Error: shovel not found!!") courseplay.onStopCpAIDriver(self.vehicle,AIVehicle.STOP_REASON_UNKOWN) return end + self.currentDischargeNode = self.shovel:getCurrentDischargeNode() self.targetUnloadingNode = nil self.lastDistanceToEmptyPoint = math.huge self:changeShovelState(self.states.DRIVING_UNLOADING_COURSE) @@ -86,6 +86,7 @@ function ShovelAIDriver:start(startingPoint) self.oldCanDischargeToGround = self.currentDischargeNode.canDischargeToGround self.currentDischargeNode.canDischargeToGround = false + --- Not sure what this is for, old code ? local vAI = self.vehicle:getAttachedImplements() for i,_ in pairs(vAI) do local object = vAI[i].object @@ -110,6 +111,17 @@ function ShovelAIDriver:start(startingPoint) end end +function ShovelAIDriver:findShovelRecursive(object) + if SpecializationUtil.hasSpecialization(Shovel, object.specializations) and not self.shovel then + self.shovel = object + return + end + + for _,impl in pairs(object:getAttachedImplements()) do + self:findShovelRecursive(impl.object) + end +end + function ShovelAIDriver:stop(msg) self.currentDischargeNode.canDischargeToGround = self.oldCanDischargeToGround self.oldCanDischargeToGround = nil @@ -619,4 +631,8 @@ end function ShovelAIDriver:isAlignmentCourseNeeded(course, ix) return AIDriver.isAlignmentCourseNeeded(self,course, ix) +end + +function ShovelAIDriver:setLightsMask(vehicle) + vehicle:setLightsTypesMask(courseplay.lights.HEADLIGHT_FULL) end \ No newline at end of file diff --git a/modDesc.xml b/modDesc.xml index 86c9b6bf7..a912ae4fd 100644 --- a/modDesc.xml +++ b/modDesc.xml @@ -1,6 +1,6 @@ - 6.4.0.1 + 6.4.0.2 <en>CoursePlay</en>