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

Commit

Permalink
6.03.00060 Speed and other fixes
Browse files Browse the repository at this point in the history
- fixes div. cruise control speed #3727
- fixes hud speed display in mph #6041
- should fix f1 menu refresh after open/close hud action event #7143
- fixes beacon lights mode 1 #6197
  • Loading branch information
schwiti6190 committed May 12, 2021
1 parent 3c6a826 commit 0ef6da2
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 33 deletions.
1 change: 1 addition & 0 deletions ActionEventsLoader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ ActionEventCallbacks = {}
]]--
function ActionEventCallbacks.actionEventOpenCloseHud(vehicle, actionName, inputValue, callbackState, isAnalog)
courseplay:openCloseHud(vehicle, not vehicle.cp.hud.show)
ActionEventsLoader.updateAllActionEvents(vehicle)
end

function ActionEventCallbacks.actionEventNextDriverMode(vehicle, actionName, inputValue, callbackState, isAnalog)
Expand Down
9 changes: 0 additions & 9 deletions FieldworkAIDriver.lua
Original file line number Diff line number Diff line change
Expand Up @@ -737,15 +737,6 @@ function FieldworkAIDriver:shouldReturnToFirstPoint()
end
end

--- Pass on self.speed set elsewhere to the AIDriver.
function FieldworkAIDriver:getSpeed()
local speed = AIDriver.getSpeed(self)
-- as long as other CP components mess with the cruise control we need to reset this, for example after
-- a turn
self.vehicle:setCruiseControlMaxSpeed(speed)
return speed
end

--- Start the actual work. Lower and turn on implements
function FieldworkAIDriver:startWork()
self:debug('Starting work: turn on and lower implements.')
Expand Down
5 changes: 0 additions & 5 deletions GrainTransportAIDriver.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ end
function GrainTransportAIDriver:start(startingPoint)
self.readyToLoadManualAtStart = false
self.nextClosestExactFillRootNode = nil
self.vehicle:setCruiseControlMaxSpeed(self.vehicle:getSpeedLimit() or math.huge)
AIDriver.start(self, startingPoint)
self.firstWaypointNode = WaypointNode('firstWaypoint')
self.firstWaypointNode:setToWaypoint(self.course, 1, true)
Expand Down Expand Up @@ -173,10 +172,6 @@ function GrainTransportAIDriver:getMaxFillLevel()
return self.vehicle.cp.settings.driveOnAtFillLevel:get() or 99
end

function GrainTransportAIDriver:updateLights()
self.vehicle:setBeaconLightsVisibility(false)
end

function GrainTransportAIDriver:getSiloSelectedFillTypeSetting()
return self.vehicle.cp.settings.siloSelectedFillTypeGrainTransportDriver
end
Expand Down
21 changes: 20 additions & 1 deletion base.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1258,6 +1258,16 @@ function courseplay.processSowingMachineArea(tool,originalFunction, superFunc, w
end
FertilizingSowingMachine.processSowingMachineArea = Utils.overwrittenFunction(FertilizingSowingMachine.processSowingMachineArea, courseplay.processSowingMachineArea)

---Speed limit is disabled while cp is driving.
function courseplay.doCheckSpeedLimit(object,superFunc,...)
local rootVehicle = object:getRootVehicle()
if not rootVehicle:getIsCourseplayDriving() then
return superFunc(object,...)
else
return false
end
end


-- Tour dialog messes up the CP yes no dialogs.
function courseplay:showTourDialog()
Expand Down Expand Up @@ -1352,6 +1362,9 @@ function courseplay.onStartCpAIDriver(vehicle,helperIndex,noEventSend, startedFa
delete(collisionRoot)
end
end
---Reset the cruiseControl max speed and store it to set it back after the driver is finished.
vehicle.cpCruiseControlBackup = vehicle:getCruiseControlSpeed()
vehicle:setCruiseControlMaxSpeed(vehicle:getCruiseControlMaxSpeed())

--cp code

Expand Down Expand Up @@ -1406,7 +1419,13 @@ function courseplay.onStopCpAIDriver(vehicle, reason, noEventSend)
CpMapHotSpot.deleteMapHotSpot(vehicle)

vehicle:setCruiseControlState(Drivable.CRUISECONTROL_STATE_OFF, true)
if g_server ~= nil then

---Restoring the cruiseControl speed before cp was started.
if vehicle.cpCruiseControlBackup then
vehicle:setCruiseControlMaxSpeed(vehicle.cpCruiseControlBackup)
vehicle.cpCruiseControlBackup = nil
end
if g_server ~= nil then
WheelsUtil.updateWheelsPhysics(vehicle, 0, spec.lastSpeedReal*spec.movingDirection, 0, true, true)
end
spec.isActive = false
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="53">
<version>6.03.00059</version>
<version>6.03.00060</version>
<author><![CDATA[Courseplay.devTeam]]></author>
<title><!-- en=English de=German fr=French es=Spanish ru=Russian pl=Polish it=Italian br=Brazilian-Portuguese cs=Chinese(Simplified) ct=Chinese(Traditional) cz=Czech nl=Netherlands hu=Hungary jp=Japanese kr=Korean pt=Portuguese ro=Romanian tr=Turkish -->
<en>CoursePlay SIX</en>
Expand Down
3 changes: 2 additions & 1 deletion register.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ function courseplay.registerEventListeners(vehicleType)
end

function courseplay.registerOverwrittenFunctions(vehicleType)
SpecializationUtil.registerOverwrittenFunction(vehicleType, "updateAILowFrequency", AIDriver.updateAILowFrequency)
SpecializationUtil.registerOverwrittenFunction(vehicleType, "updateAILowFrequency", AIDriver.updateAILowFrequency)
SpecializationUtil.registerOverwrittenFunction(vehicleType, "doCheckSpeedLimit", courseplay.doCheckSpeedLimit)
end

-- Register interface functions to start/stop the Courseplay driver
Expand Down
8 changes: 7 additions & 1 deletion settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1720,11 +1720,17 @@ function SpeedSetting:init(name, label, toolTip, vehicle,startValue,stopValue)
for i=1,stopValue-startValue do
local x = startValue+i-1
values[i] = x
texts[i] = ('%i %s'):format(x, courseplay:getSpeedMeasuringUnit());
texts[i] = x
end
SettingList.init(self, name, label, toolTip, vehicle,values, texts)
end

function SpeedSetting:getText()
local speed = self.texts[self.current] ---in km/h

return string.format("%i %s",g_i18n:getSpeed(speed),g_i18n:getSpeedMeasuringUnit())
end

-- Generic IntSetting with power of x (for example 0.1)
---@class IntSettingScientific
IntSettingScientific = CpObject(IntSetting)
Expand Down
15 changes: 0 additions & 15 deletions start_stop.lua
Original file line number Diff line number Diff line change
Expand Up @@ -90,20 +90,13 @@ function courseplay:start(self)

courseplay:updateAllTriggers();

self.cp.cruiseControlSpeedBackup = self:getCruiseControlSpeed();

-- ok i am near the waypoint, let's go
self.cp.savedCheckSpeedLimit = self.checkSpeedLimit;
self.checkSpeedLimit = false
---Do we need to set distanceCheck==true at the beginning of courseplay:start() and set now set it to false 50 lines later ??
-- self.cp.distanceCheck = false

self.cp.totalLength, self.cp.totalLengthOffset = courseplay:getTotalLengthOnWheels(self);

courseplay:validateCanSwitchMode(self);



-- and another ugly hack here as when settings.lua setAIDriver() is called the bale loader does not seem to be
-- attached and I don't have the motivation do dig through the legacy code to find out why
if self.cp.mode == courseplay.MODE_FIELDWORK then
Expand Down Expand Up @@ -137,14 +130,7 @@ function courseplay:stop(self)
self.cp.directionNodeToTurnNodeLength = nil
end

---This is not working correctly on the server!
if self.cp.cruiseControlSpeedBackup then
self.spec_drivable.cruiseControl.speed = self.cp.cruiseControlSpeedBackup; -- NOTE JT: no need to use setter or event function - Drivable's update() checks for changes in the var and calls the event itself
self.cp.cruiseControlSpeedBackup = nil;
end;


self.spec_drivable.cruiseControl.minSpeed = 1
self.cp.settings.forcedToStop:set(false)
self.cp.waitingForTrailerToUnload = false

Expand All @@ -155,7 +141,6 @@ function courseplay:stop(self)
self.cp.hasMachineToFill = false;

-- resetting variables
self.checkSpeedLimit = self.cp.savedCheckSpeedLimit;
courseplay:resetTipTrigger(self);

if self.cp.checkReverseValdityPrinted then
Expand Down

0 comments on commit 0ef6da2

Please sign in to comment.