Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions scripts/ai/controllers/MotorController.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,8 @@ function MotorController:update()
if not self.isValid then
return
end
if not self.settings.fuelSave:getValue() then
if not self:getIsStarted() then
self:startMotor()
self.vehicle:raiseAIEvent('onAIFieldWorkerContinue', 'onAIImplementContinue')
end
self.timerSet = false
return
end
if self:isFuelSaveDisabled() or self.driveStrategy:getMaxSpeed() >
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be more comfortable with this if we changed this to an elseif to prevent the rest of motor starting logic to run.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this makes the first two blocks functionally identical, I pushed a slightly different change that just condenses the two.

self.speedThreshold then
self.speedThreshold or not self.settings.fuelSave:getValue() then
if not self:getIsStarted() then
self:startMotor()
self.vehicle:raiseAIEvent("onAIFieldWorkerContinue", "onAIImplementContinue")
Expand Down Expand Up @@ -85,7 +77,7 @@ function MotorController:getDriveData()
end
if g_Courseplay.globalSettings.waitForRefueling:getValue() and
self:isFuelLow(self.fuelThresholdSetting:getValue()) then

maxSpeed = 0
end

Expand Down Expand Up @@ -132,4 +124,4 @@ end

function MotorController:getIsStarted()
return self.vehicle:getMotorState() ~= MotorState.OFF
end
end