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

Commit

Permalink
PR fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
schwiti6190 committed Jul 16, 2021
1 parent 1b4c3a3 commit 598dc3c
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 40 deletions.
3 changes: 1 addition & 2 deletions CombineUnloadAIDriver.lua
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,8 @@ function CombineUnloadAIDriver:start(startingPoint)

self.unloadCourse = Course(self.vehicle, self.vehicle.Waypoints)
self.ppc:setNormalLookaheadDistance()

self:setDriveUnloadNow(false)

if startingPoint:is(StartingPointSetting.START_WITH_UNLOAD) then
if CpManager.isDeveloper then
-- automatically select closest combine
Expand Down
7 changes: 4 additions & 3 deletions CombineUnloadManager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,10 @@ function CombineUnloadManager:giveMeACombineToUnload(unloader)
self:debug('Combine with most fill level is %s', nameNum(combine))
local bestUnloader
if combine ~= nil and combine.cp.driver:getFieldworkCourse() then
if combine.cp.settings.combineWantsCourseplayer:is(true) then
if combine.cp.settings.requestUnloader:is(true) then
self:addUnloaderToCombine(unloader,combine)
combine.cp.settings.combineWantsCourseplayer:set(false)
combine.cp.settings.requestUnloader:set(false)
combine.cp.driver:refreshHUD()
return combine
end
local num = self:getUnloadersNumber(unloader, combine)
Expand Down Expand Up @@ -260,7 +261,7 @@ function CombineUnloadManager:getCombineWithMostFillLevel(unloader)
self:debug('For unloader %s: %s (fill level %.1f, ready to unload: %s) has %d unloaders, this unloader is # %d',
nameNum(unloader), nameNum(combine), fillLevelPct, tostring(combineReadyToUnload), numUnloaders, unloaderIndex or -1)
if data and data.isCombine and (numUnloaders == 0 or unloaderIndex == 1) and combineReadyToUnload then
if combine.cp.settings.combineWantsCourseplayer:is(true) then
if combine.cp.settings.requestUnloader:is(true) then
return combine
end
if mostFillLevel < fillLevelPct then
Expand Down
22 changes: 11 additions & 11 deletions hud.lua
Original file line number Diff line number Diff line change
Expand Up @@ -946,20 +946,20 @@ function courseplay.hud:updatePageContent(vehicle, page)
end
end
end
elseif entry.functionToCall == 'combineWantsCourseplayer:toggle' then
--CombineWantsCourseplayerSetting
elseif entry.functionToCall == 'requestUnloader:toggle' then
--requestUnloaderSetting
if not g_combineUnloadManager:getHasUnloaders(vehicle) then
self:enableButtonWithFunction(vehicle,page, 'toggle',vehicle.cp.settings.combineWantsCourseplayer)
if vehicle.cp.settings.combineWantsCourseplayer:is(true) then
vehicle.cp.hud.content.pages[page][line][1].text = vehicle.cp.settings.combineWantsCourseplayer:getText()
self:enableButtonWithFunction(vehicle,page, 'toggle',vehicle.cp.settings.requestUnloader)
if vehicle.cp.settings.requestUnloader:is(true) then
vehicle.cp.hud.content.pages[page][line][1].text = vehicle.cp.settings.requestUnloader:getText()
else
vehicle.cp.hud.content.pages[page][line][1].text = vehicle.cp.settings.combineWantsCourseplayer:getText()
vehicle.cp.hud.content.pages[page][line][1].text = vehicle.cp.settings.requestUnloader:getText()
end
else
local courseplayer = g_combineUnloadManager:getUnloaderByNumber(1, vehicle)
self:disableButtonWithFunction(vehicle,page, 'toggle',vehicle.cp.settings.combineWantsCourseplayer)
vehicle.cp.hud.content.pages[page][line][1].text = vehicle.cp.settings.combineWantsCourseplayer:getLabel()
vehicle.cp.hud.content.pages[page][line][2].text = courseplayer.name;
local unloader = g_combineUnloadManager:getUnloaderByNumber(1, vehicle)
self:disableButtonWithFunction(vehicle,page, 'toggle',vehicle.cp.settings.requestUnloader)
vehicle.cp.hud.content.pages[page][line][1].text = vehicle.cp.settings.requestUnloader:getLabel()
vehicle.cp.hud.content.pages[page][line][2].text = unloader.name;
end
elseif entry.functionToCall == 'startStopCourseplayer' then
if g_combineUnloadManager:getHasUnloaders(vehicle) then
Expand Down Expand Up @@ -2148,7 +2148,7 @@ function courseplay.hud:setCombineAIDriverContent(vehicle)
self:debug(vehicle,"setCombineAIDriverContent")
--page 0
self:enablePageButton(vehicle, 0)
self:addRowButton(vehicle,vehicle.cp.settings.combineWantsCourseplayer,'toggle', 0, 1, 1 )
self:addRowButton(vehicle,vehicle.cp.settings.requestUnloader,'toggle', 0, 1, 1 )
self:addRowButton(vehicle,nil,'startStopCourseplayer', 0, 2, 1 )
self:addRowButton(vehicle,nil,'sendCourseplayerHome', 0, 3, 1 )
if vehicle.cp.isChopper then
Expand Down
40 changes: 16 additions & 24 deletions settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ end;
function courseplay:sendCourseplayerHome(combine)
local unloader = g_combineUnloadManager:getUnloaderByNumber(1, combine)
if unloader then
unloader.cp.driver:setDriveUnloadNow()
unloader.cp.driver:setDriveUnloadNow(true)
end
end
function courseplay:setHudPage(vehicle, pageNum)
Expand Down Expand Up @@ -1625,30 +1625,22 @@ end
--- Set the next value
function DriverModeSetting:setNext()
if not self:isDisabled() then
for i=1,self.NUM_MODES do
local targetMode = self:get() + i
if targetMode > self.NUM_MODES then
targetMode = targetMode - self.NUM_MODES
end
if courseplay:getIsToolCombiValidForCpMode(self.vehicle,targetMode) then
self:setToIx(targetMode)
end
end
local targetMode = self.current
repeat
targetMode = SettingList.checkAndSetValidValue(self, targetMode + 1)
until courseplay:getIsToolCombiValidForCpMode(self.vehicle, self.values[targetMode])
self:setToIx(targetMode)
end
end

--- Set the previous value
function DriverModeSetting:setPrevious()
if not self:isDisabled() then
for i=1,self.NUM_MODES do
local targetMode = self:get() - i
if targetMode < 1 then
targetMode = self.NUM_MODES + targetMode
end
if courseplay:getIsToolCombiValidForCpMode(self.vehicle,targetMode) then
self:setToIx(targetMode)
end
end
local targetMode = self.current
repeat
targetMode = SettingList.checkAndSetValidValue(self, targetMode - 1)
until courseplay:getIsToolCombiValidForCpMode(self.vehicle, self.values[targetMode])
self:setToIx(targetMode)
end
end

Expand Down Expand Up @@ -2411,10 +2403,10 @@ function DriveUnloadNowSetting:init(vehicle)
self:set(false)
end

---@class CombineWantsCourseplayerSetting : BooleanSetting
CombineWantsCourseplayerSetting = CpObject(BooleanSetting)
function CombineWantsCourseplayerSetting:init(vehicle)
BooleanSetting.init(self, 'combineWantsCourseplayer', 'COURSEPLAY_DRIVER', 'COURSEPLAY_DRIVER', vehicle, {'COURSEPLAY_REQUEST_UNLOADING_DRIVER','COURSEPLAY_UNLOADING_DRIVER_REQUESTED'})
---@class RequestUnloaderSetting : BooleanSetting
RequestUnloaderSetting = CpObject(BooleanSetting)
function RequestUnloaderSetting:init(vehicle)
BooleanSetting.init(self, 'requestUnloader', 'COURSEPLAY_DRIVER', 'COURSEPLAY_DRIVER', vehicle, {'COURSEPLAY_REQUEST_UNLOADING_DRIVER','COURSEPLAY_UNLOADING_DRIVER_REQUESTED'})
self:set(false)
end

Expand Down Expand Up @@ -4129,7 +4121,7 @@ function SettingsContainer.createVehicleSpecificSettings(vehicle)
container:addSetting(AlwaysSearchFuelSetting, vehicle)
container:addSetting(RealisticDrivingSetting, vehicle)
container:addSetting(DriveUnloadNowSetting, vehicle)
container:addSetting(CombineWantsCourseplayerSetting, vehicle)
container:addSetting(RequestUnloaderSetting, vehicle)
container:addSetting(TurnOnFieldSetting, vehicle)
container:addSetting(GrainTransportDriver_SiloSelectedFillTypeSetting, vehicle)
container:addSetting(FillableFieldWorkDriver_SiloSelectedFillTypeSetting, vehicle)
Expand Down

0 comments on commit 598dc3c

Please sign in to comment.