Skip to content
This repository was archived by the owner on Jan 19, 2019. It is now read-only.

Commit b4b6b64

Browse files
committed
v2.0.5.1
hand brake and atriculated axis #115 brake for vehicle:getSpeedLimit(true) #100
1 parent 38e47e7 commit b4b6b64

File tree

4 files changed

+81
-33
lines changed

4 files changed

+81
-33
lines changed

FS17_GearboxAddon.zip

115 Bytes
Binary file not shown.

FS17_GearboxAddon/gearboxMogli.lua

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -917,8 +917,8 @@ function gearboxMogli:initFromXml(xmlFile,xmlString,xmlSource,serverAndClient,mo
917917
end
918918

919919
self.mrGbMS.ClutchTimeInc = Utils.getNoNil(getXMLFloat(xmlFile, xmlString .. "#clutchTimeIncreaseMs"), clutchEngagingTimeMs )
920-
self.mrGbMS.ClutchTimeDec = Utils.getNoNil(getXMLFloat(xmlFile, xmlString .. "#clutchTimeDecreaseMs"), 0.50 * clutchEngagingTimeMs )
921-
self.mrGbMS.ClutchShiftTime = Utils.getNoNil(getXMLFloat(xmlFile, xmlString .. "#clutchShiftingTimeMs"), 0.25 * self.mrGbMS.ClutchTimeDec)
920+
self.mrGbMS.ClutchTimeDec = Utils.getNoNil(getXMLFloat(xmlFile, xmlString .. "#clutchTimeDecreaseMs"), clutchEngagingTimeMs )
921+
self.mrGbMS.ClutchShiftTime = Utils.getNoNil(getXMLFloat(xmlFile, xmlString .. "#clutchShiftingTimeMs"), 2 * self.mrGbMS.ClutchTimeDec)
922922
self.mrGbMS.ClutchTimeManual = math.max( Utils.getNoNil(getXMLFloat(xmlFile, xmlString .. "#clutchTimeManualMs"), self.mrGbMG.minClutchTimeManual ), self.mrGbMS.ClutchTimeInc )
923923
self.mrGbMS.ClutchCanOverheat = Utils.getNoNil(getXMLBool( xmlFile, xmlString .. "#clutchCanOverheat"), not self.mrGbMS.TorqueConverterOrHydro )
924924
self.mrGbMS.ClutchOverheatStartTime = Utils.getNoNil(getXMLFloat(xmlFile, xmlString .. "#clutchOverheatStartTimeMs"), 5000 )
@@ -2511,9 +2511,9 @@ function gearboxMogli:update(dt)
25112511
end
25122512

25132513
local clutchSpeed = 1 / math.max( self.mrGbMS.ClutchShiftTime, 1 )
2514-
if not ( self:mrGbMGetAutoClutch() ) then
2515-
clutchSpeed = math.max( 0.002, clutchSpeed )
2516-
end
2514+
--if not ( self:mrGbMGetAutoClutch() ) then
2515+
-- clutchSpeed = math.max( 0.002, clutchSpeed )
2516+
--end
25172517

25182518
if gearboxMogli.mbIsInputPressed( "gearboxMogliCLUTCH_3" ) then
25192519
self.mrGbML.oneButtonClutchTimer = g_currentMission.time + 100
@@ -5915,6 +5915,17 @@ function gearboxMogli:newUpdateWheelsPhysics( superFunc, dt, currentSpeed, acc,
59155915
end
59165916
end
59175917

5918+
do
5919+
local cs = currentSpeed * 3600
5920+
local sl = self:getSpeedLimit(true) + gearboxMogli.extraSpeedLimit
5921+
if cs >= sl + 1 then
5922+
brakePedal = 1
5923+
brakeLights = true
5924+
elseif cs > sl then
5925+
brakePedal = math.max( brakePedal, cs - sl )
5926+
end
5927+
end
5928+
59185929
self.motor:updateSpeedLimit( dt )
59195930

59205931
if self.tempomatMogliV17 ~= nil
@@ -5923,9 +5934,19 @@ function gearboxMogli:newUpdateWheelsPhysics( superFunc, dt, currentSpeed, acc,
59235934
brakeLights = true
59245935
end
59255936

5937+
local lastRotatedTime = self.mrGbML.lastRotatedTime
5938+
self.mrGbML.lastRotatedTime = nil
5939+
59265940
if doHandbrake or self.mrGbMS.AutoHold or not ( self.isMotorStarted ) or g_currentMission.time < self.motorStartTime then
59275941
-- hand brake
5928-
if math.abs(self.rotatedTime) < 0.01 or self.articulatedAxis == nil then
5942+
if self.articulatedAxis ~= nil then
5943+
if lastRotatedTime == nil then
5944+
brakePedal = 1
5945+
else
5946+
brakePedal = 1 - 0.5 * ( lastRotatedTime - self.rotatedTime )
5947+
end
5948+
self.mrGbML.lastRotatedTime = self.rotatedTime
5949+
else
59295950
brakePedal = 1
59305951
end
59315952
elseif acceleration < 0 then
@@ -5941,11 +5962,14 @@ function gearboxMogli:newUpdateWheelsPhysics( superFunc, dt, currentSpeed, acc,
59415962

59425963

59435964
if ( self:mrGbMGetAutoHold() or ( self:mrGbMGetAutoClutch() and acceleration > 0.001 ) )
5944-
and ( ( self.movingDirection * currentSpeed > 2.7777777778e-4 and self.mrGbMS.ReverseActive )
5945-
or ( self.movingDirection * currentSpeed < -2.7777777778e-4 and not ( self.mrGbMS.ReverseActive ) ) ) then
5946-
-- wrong direction
5947-
brakePedal = 1
5948-
brakeLights = true
5965+
and ( ( self.movingDirection * currentSpeed > 0 and self.mrGbMS.ReverseActive )
5966+
or ( self.movingDirection * currentSpeed < 0 and not ( self.mrGbMS.ReverseActive ) ) ) then
5967+
-- wrong direction
5968+
local b = math.min( 1, 1800 * math.abs( currentSpeed ) )
5969+
if b >= 0.5 then
5970+
brakeLights = true
5971+
end
5972+
brakePedal = math.max( b, brakePedal )
59495973
end
59505974

59515975
if self:mrGbMGetAutoHold()
@@ -5981,7 +6005,7 @@ function gearboxMogli:newUpdateWheelsPhysics( superFunc, dt, currentSpeed, acc,
59816005

59826006
brakePedal = math.max( brakePedal, brakeForce )
59836007

5984-
if self.motor.clutchPercent < gearboxMogli.minClutchPercent + gearboxMogli.minClutchPercent then
6008+
if self.motor.clutchPercent < gearboxMogli.minClutchPercent then
59856009
c = 0
59866010
else
59876011
local cp = self.motor.clutchPercent
@@ -7930,7 +7954,7 @@ function gearboxMogliMotor:mrGbMUpdateGear( accelerationPedal )
79307954
self.vehicle:mrGbMDoGearShift()
79317955
self.vehicle.mrGbML.gearShiftingNeeded = 0
79327956

7933-
elseif not ( self.vehicle:mrGbMGetAutoClutch() ) and self.vehicle.mrGbMS.ManualClutch < self.vehicle.mrGbMS.MinClutchPercent + 0.1 then
7957+
elseif not ( self.vehicle:mrGbMGetAutoClutch() ) and self.vehicle.mrGbMS.ManualClutch < gearboxMogli.minClutchPercent then
79347958
--**********************************************************************************************************
79357959
-- manual clutch pressed
79367960
self.noTransmission = true

FS17_GearboxAddon/modDesc.xml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
<modDesc descVersion="32">
33
<author>Mogli aka Biedens</author>
44
<iconFilename>dds/store.dds</iconFilename>
5-
<version>2.0.5.0</version>
5+
<version>2.0.5.1</version>
66
<multiplayer supported="true"/>
77

88
<l10n filenamePrefix="modDesc_l10n">
99
<text name="gearboxMogliVERSION">
10-
<de>Getriebe v2.0.5.0 von Mogli</de>
11-
<en>Gearbox v2.0.5.0 by mogli</en>
12-
<it>Cambio v2.0.5.0 by mogli</it>
13-
<fr>Transmission v2.0.5.0 by mogli</fr>
14-
<cz>Řazení v2.0.5.0 by mogli</cz>
15-
<pl>Skrzynia biegów v2.0.5.0 by mogli</pl>
10+
<de>Getriebe v2.0.5.1 von Mogli</de>
11+
<en>Gearbox v2.0.5.1 by mogli</en>
12+
<it>Cambio v2.0.5.1 by mogli</it>
13+
<fr>Transmission v2.0.5.1 by mogli</fr>
14+
<cz>Řazení v2.0.5.1 by mogli</cz>
15+
<pl>Skrzynia biegów v2.0.5.1 by mogli</pl>
1616
</text>
1717
</l10n>
1818

src/gearboxMogli.lua

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -917,8 +917,8 @@ function gearboxMogli:initFromXml(xmlFile,xmlString,xmlSource,serverAndClient,mo
917917
end
918918

919919
self.mrGbMS.ClutchTimeInc = Utils.getNoNil(getXMLFloat(xmlFile, xmlString .. "#clutchTimeIncreaseMs"), clutchEngagingTimeMs )
920-
self.mrGbMS.ClutchTimeDec = Utils.getNoNil(getXMLFloat(xmlFile, xmlString .. "#clutchTimeDecreaseMs"), 0.50 * clutchEngagingTimeMs )
921-
self.mrGbMS.ClutchShiftTime = Utils.getNoNil(getXMLFloat(xmlFile, xmlString .. "#clutchShiftingTimeMs"), 0.25 * self.mrGbMS.ClutchTimeDec)
920+
self.mrGbMS.ClutchTimeDec = Utils.getNoNil(getXMLFloat(xmlFile, xmlString .. "#clutchTimeDecreaseMs"), clutchEngagingTimeMs )
921+
self.mrGbMS.ClutchShiftTime = Utils.getNoNil(getXMLFloat(xmlFile, xmlString .. "#clutchShiftingTimeMs"), 2 * self.mrGbMS.ClutchTimeDec)
922922
self.mrGbMS.ClutchTimeManual = math.max( Utils.getNoNil(getXMLFloat(xmlFile, xmlString .. "#clutchTimeManualMs"), self.mrGbMG.minClutchTimeManual ), self.mrGbMS.ClutchTimeInc )
923923
self.mrGbMS.ClutchCanOverheat = Utils.getNoNil(getXMLBool( xmlFile, xmlString .. "#clutchCanOverheat"), not self.mrGbMS.TorqueConverterOrHydro )
924924
self.mrGbMS.ClutchOverheatStartTime = Utils.getNoNil(getXMLFloat(xmlFile, xmlString .. "#clutchOverheatStartTimeMs"), 5000 )
@@ -2511,9 +2511,9 @@ function gearboxMogli:update(dt)
25112511
end
25122512

25132513
local clutchSpeed = 1 / math.max( self.mrGbMS.ClutchShiftTime, 1 )
2514-
if not ( self:mrGbMGetAutoClutch() ) then
2515-
clutchSpeed = math.max( 0.002, clutchSpeed )
2516-
end
2514+
--if not ( self:mrGbMGetAutoClutch() ) then
2515+
-- clutchSpeed = math.max( 0.002, clutchSpeed )
2516+
--end
25172517

25182518
if gearboxMogli.mbIsInputPressed( "gearboxMogliCLUTCH_3" ) then
25192519
self.mrGbML.oneButtonClutchTimer = g_currentMission.time + 100
@@ -5915,6 +5915,17 @@ function gearboxMogli:newUpdateWheelsPhysics( superFunc, dt, currentSpeed, acc,
59155915
end
59165916
end
59175917

5918+
do
5919+
local cs = currentSpeed * 3600
5920+
local sl = self:getSpeedLimit(true) + gearboxMogli.extraSpeedLimit
5921+
if cs >= sl + 1 then
5922+
brakePedal = 1
5923+
brakeLights = true
5924+
elseif cs > sl then
5925+
brakePedal = math.max( brakePedal, cs - sl )
5926+
end
5927+
end
5928+
59185929
self.motor:updateSpeedLimit( dt )
59195930

59205931
if self.tempomatMogliV17 ~= nil
@@ -5923,9 +5934,19 @@ function gearboxMogli:newUpdateWheelsPhysics( superFunc, dt, currentSpeed, acc,
59235934
brakeLights = true
59245935
end
59255936

5937+
local lastRotatedTime = self.mrGbML.lastRotatedTime
5938+
self.mrGbML.lastRotatedTime = nil
5939+
59265940
if doHandbrake or self.mrGbMS.AutoHold or not ( self.isMotorStarted ) or g_currentMission.time < self.motorStartTime then
59275941
-- hand brake
5928-
if math.abs(self.rotatedTime) < 0.01 or self.articulatedAxis == nil then
5942+
if self.articulatedAxis ~= nil then
5943+
if lastRotatedTime == nil then
5944+
brakePedal = 1
5945+
else
5946+
brakePedal = 1 - 0.5 * ( lastRotatedTime - self.rotatedTime )
5947+
end
5948+
self.mrGbML.lastRotatedTime = self.rotatedTime
5949+
else
59295950
brakePedal = 1
59305951
end
59315952
elseif acceleration < 0 then
@@ -5941,11 +5962,14 @@ function gearboxMogli:newUpdateWheelsPhysics( superFunc, dt, currentSpeed, acc,
59415962

59425963

59435964
if ( self:mrGbMGetAutoHold() or ( self:mrGbMGetAutoClutch() and acceleration > 0.001 ) )
5944-
and ( ( self.movingDirection * currentSpeed > 2.7777777778e-4 and self.mrGbMS.ReverseActive )
5945-
or ( self.movingDirection * currentSpeed < -2.7777777778e-4 and not ( self.mrGbMS.ReverseActive ) ) ) then
5946-
-- wrong direction
5947-
brakePedal = 1
5948-
brakeLights = true
5965+
and ( ( self.movingDirection * currentSpeed > 0 and self.mrGbMS.ReverseActive )
5966+
or ( self.movingDirection * currentSpeed < 0 and not ( self.mrGbMS.ReverseActive ) ) ) then
5967+
-- wrong direction
5968+
local b = math.min( 1, 1800 * math.abs( currentSpeed ) )
5969+
if b >= 0.5 then
5970+
brakeLights = true
5971+
end
5972+
brakePedal = math.max( b, brakePedal )
59495973
end
59505974

59515975
if self:mrGbMGetAutoHold()
@@ -5981,7 +6005,7 @@ function gearboxMogli:newUpdateWheelsPhysics( superFunc, dt, currentSpeed, acc,
59816005

59826006
brakePedal = math.max( brakePedal, brakeForce )
59836007

5984-
if self.motor.clutchPercent < gearboxMogli.minClutchPercent + gearboxMogli.minClutchPercent then
6008+
if self.motor.clutchPercent < gearboxMogli.minClutchPercent then
59856009
c = 0
59866010
else
59876011
local cp = self.motor.clutchPercent
@@ -7930,7 +7954,7 @@ function gearboxMogliMotor:mrGbMUpdateGear( accelerationPedal )
79307954
self.vehicle:mrGbMDoGearShift()
79317955
self.vehicle.mrGbML.gearShiftingNeeded = 0
79327956

7933-
elseif not ( self.vehicle:mrGbMGetAutoClutch() ) and self.vehicle.mrGbMS.ManualClutch < self.vehicle.mrGbMS.MinClutchPercent + 0.1 then
7957+
elseif not ( self.vehicle:mrGbMGetAutoClutch() ) and self.vehicle.mrGbMS.ManualClutch < gearboxMogli.minClutchPercent then
79347958
--**********************************************************************************************************
79357959
-- manual clutch pressed
79367960
self.noTransmission = true

0 commit comments

Comments
 (0)