diff --git a/ActionEventsLoader.lua b/ActionEventsLoader.lua index ebe5de2f7..ff12fa7bf 100644 --- a/ActionEventsLoader.lua +++ b/ActionEventsLoader.lua @@ -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) diff --git a/FieldworkAIDriver.lua b/FieldworkAIDriver.lua index 783a34fc3..394e913b3 100644 --- a/FieldworkAIDriver.lua +++ b/FieldworkAIDriver.lua @@ -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.') diff --git a/GrainTransportAIDriver.lua b/GrainTransportAIDriver.lua index af9c60e8f..dda994f03 100644 --- a/GrainTransportAIDriver.lua +++ b/GrainTransportAIDriver.lua @@ -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) @@ -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 diff --git a/base.lua b/base.lua index f879bbdaf..4abd82033 100644 --- a/base.lua +++ b/base.lua @@ -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() @@ -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 @@ -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 diff --git a/modDesc.xml b/modDesc.xml index 13b6ed2e5..25e2c119d 100644 --- a/modDesc.xml +++ b/modDesc.xml @@ -1,6 +1,6 @@ - 6.03.00059 + 6.03.00060 <!-- 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> diff --git a/register.lua b/register.lua index 5fd6efebc..30f66465b 100644 --- a/register.lua +++ b/register.lua @@ -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 diff --git a/settings.lua b/settings.lua index 6a885e503..bb0e6cb49 100644 --- a/settings.lua +++ b/settings.lua @@ -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) diff --git a/start_stop.lua b/start_stop.lua index 1578f4285..336401379 100644 --- a/start_stop.lua +++ b/start_stop.lua @@ -90,11 +90,6 @@ 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 @@ -102,8 +97,6 @@ function courseplay:start(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 @@ -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 @@ -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