@@ -124,19 +124,23 @@ function Handlers.Driving(mod, activity)
124
124
local vehicleName = GameUtils .GetVehicleName (vehicle )
125
125
if vehicleName and vehicle :IsPlayerDriver () then
126
126
local speedUnit = mod .speedAsMPH and " mph" or " km/h"
127
- -- 2.23693629192 is 3.6 * 0.6213711922 where the latter number is the conversion factor between km/h and mph
128
- local vehicleSpeed = math.floor (vehicle :GetCurrentSpeed () * (mod .speedAsMPH and 2.23693629192 or 3.6 ) + .5 )
127
+ local vehicleSpeed , goingForward = GameUtils .GetVehicleSpeed (vehicle )
128
+ -- 1.609344 is the conversion factor from mph to km/h
129
+ if not mod .speedAsMPH then vehicleSpeed = vehicleSpeed * 1.609344 ; end
130
+ -- local vehicleSpeed = math.floor(vehicle:GetCurrentSpeed() * (mod.speedAsMPH and 2.23693629192 or 3.6) + .5)
129
131
local activityVars = Handlers .SetCommonInfo (mod , activity , {
130
132
vehicle = vehicleName ,
131
- speed = math.abs (vehicleSpeed ),
133
+ speed = math.floor (vehicleSpeed + .5 ),
132
134
speedUnit = speedUnit
133
135
})
134
136
135
137
activity .Details = mod .Localization :GetFormatted (" Driving.Details" , activityVars )
136
- if vehicleSpeed > 0 then
137
- activity .State = mod .Localization :GetFormatted (" Driving.State.Forward" , activityVars )
138
- elseif vehicleSpeed < 0 then
139
- activity .State = mod .Localization :GetFormatted (" Driving.State.Backwards" , activityVars )
138
+ if vehicleSpeed >= 1 then
139
+ if goingForward then
140
+ activity .State = mod .Localization :GetFormatted (" Driving.State.Forward" , activityVars )
141
+ else
142
+ activity .State = mod .Localization :GetFormatted (" Driving.State.Backwards" , activityVars )
143
+ end
140
144
else
141
145
activity .State = mod .Localization :GetFormatted (" Driving.State.Parked" , activityVars )
142
146
end
0 commit comments