Skip to content

Commit

Permalink
6.01.00192: added plough option to HUD
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasGaertner committed Apr 17, 2019
1 parent 5a451ea commit deae564
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 14 deletions.
21 changes: 13 additions & 8 deletions FieldworkAIDriver.lua
Original file line number Diff line number Diff line change
Expand Up @@ -252,17 +252,22 @@ end

function FieldworkAIDriver:checkFillLevels()
if not self:allFillLevelsOk() or self.heldForUnloadRefill then
if self.unloadRefillCourse and not self.heldForUnloadRefill then
self:rememberWaypointToContinueFieldwork()
self:debug('at least one tool is empty/full, aborting work at waypoint %d.', self.continueFieldworkAtWaypoint or -1)
self:changeToUnloadOrRefill()
self:startCourseWithPathfinding(self.unloadRefillCourse, 1, true)
else
self:changeToFieldworkUnloadOrRefill()
end
self:stopAndChangeToUnload()
end
end

function FieldworkAIDriver:stopAndChangeToUnload()
if self.unloadRefillCourse and not self.heldForUnloadRefill then
self:rememberWaypointToContinueFieldwork()
self:debug('at least one tool is empty/full, aborting work at waypoint %d.', self.continueFieldworkAtWaypoint or -1)
self:changeToUnloadOrRefill()
self:startCourseWithPathfinding(self.unloadRefillCourse, 1, true)
else
self:changeToFieldworkUnloadOrRefill()
end
end


---@return boolean true if unload took over the driving
function FieldworkAIDriver:driveUnloadOrRefill()
if self.course:isTemporary() then
Expand Down
2 changes: 1 addition & 1 deletion UnloadableFieldworkAIDriver.lua
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ end
-- TODO: can this be refactored using FieldworkAIDriver.allFillLevelsOk()?
function UnloadableFieldworkAIDriver:allFillLevelsOk()
if not self.vehicle.cp.workTools then return false end
local allOk = not self:getDriveUnloadNow()
local allOk = true
for _, workTool in pairs(self.vehicle.cp.workTools) do
allOk = self:fillLevelsOk(workTool) and allOk
end
Expand Down
23 changes: 19 additions & 4 deletions hud.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,23 @@ function courseplay.hud:updatePageContent(vehicle, page)
self:disableButtonWithFunction(vehicle,page, 'setDriveNow')
end
end
end
end

elseif entry.functionToCall == 'forceGoToUnloadCourse' then
if not vehicle.cp.isRecording and not vehicle.cp.recordingIsPaused then
if vehicle.cp.driver and vehicle.cp.driver.getCanShowDriveOnButton then
if vehicle:getIsCourseplayDriving() and vehicle.cp.driver:getCanShowDriveOnButton() and not vehicle.cp.driveUnloadNow then
self:enableButtonWithFunction(vehicle,page, 'forceGoToUnloadCourse')
vehicle.cp.hud.content.pages[page][line][1].text = courseplay:loc('COURSEPLAY_DRIVE_NOW')
else
self:disableButtonWithFunction(vehicle,page, 'forceGoToUnloadCourse')
end
end
end




elseif entry.functionToCall == 'toggleWantsCourseplayer' then
if not vehicle.cp.driver:getHasCourseplayers() then
self:enableButtonWithFunction(vehicle,page, 'toggleWantsCourseplayer')
Expand Down Expand Up @@ -2393,16 +2409,15 @@ function courseplay.hud:setFieldWorkAIDriverContent(vehicle)
self:addSettingsRowWithArrows(vehicle,'changeToolOffsetX', 8, 5, 1 )
self:addSettingsRowWithArrows(vehicle,'changeToolOffsetZ', 8, 6, 1 )
self:addRowButton(vehicle,'toggleOppositeTurnMode', 8, 7, 1 )

--togglePlowFieldEdge
self:addRowButton(vehicle,'togglePlowFieldEdge', 8, 8, 1 )

self:setReloadPageOrder(vehicle, -1, true)
end

function courseplay.hud:setUnloadableFieldworkAIDriverContent(vehicle)
self:debug(vehicle,"setUnloadableFieldworkAIDriverContent")

self:addRowButton(vehicle,'setDriveNow', 1, 2, 3 )
self:addRowButton(vehicle,'forceGoToUnloadCourse', 1, 2, 3 )

self:addSettingsRow(vehicle,'changeRefillUntilPct', 3, 5, 1 )

Expand Down
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="40">
<version>6.01.00191</version>
<version>6.01.00192</version>
<author><![CDATA[Courseplay.devTeam]]></author>
<title>
<br>CoursePlay SIX</br>
Expand Down
5 changes: 5 additions & 0 deletions settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ function courseplay:setDriveNow(vehicle)
courseplay:setDriveUnloadNow(vehicle, true);
end

function courseplay:forceGoToUnloadCourse(vehicle)
vehicle.cp.driver:stopAndChangeToUnload()
end


function courseplay:toggleShowMiniHud(vehicle)
vehicle.cp.hud.showMiniHud = not vehicle.cp.hud.showMiniHud
end
Expand Down

0 comments on commit deae564

Please sign in to comment.