Skip to content
This repository has been archived by the owner on May 23, 2023. It is now read-only.

Commit

Permalink
Merge pull request #7277 from Courseplay/issue-7239
Browse files Browse the repository at this point in the history
Small mode 9 fixes
  • Loading branch information
Tensuko authored Jun 15, 2021
2 parents 40d6027 + e4e9d56 commit 3b6e535
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 6 deletions.
2 changes: 2 additions & 0 deletions AIDriverUtil.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion BunkerSiloAIDriver.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion BunkerSiloLoaderAIDriver.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions CompactingAIDriver.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
22 changes: 19 additions & 3 deletions ShovelAIDriver.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -71,21 +72,21 @@ 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)

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
Expand All @@ -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
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion modDesc.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<modDesc descVersion="53">
<version>6.4.0.1</version>
<version>6.4.0.2</version>
<author><![CDATA[Courseplay.devTeam]]></author>
<title>
<en>CoursePlay</en>
Expand Down

0 comments on commit 3b6e535

Please sign in to comment.