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

Commit

Permalink
v05.03.00049 MR Turn Manuver Fix
Browse files Browse the repository at this point in the history
This prevents runaway tractors on steep grades during turn manuvers
  • Loading branch information
pops64 committed Nov 13, 2018
1 parent 02907ef commit 36eae5a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
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="39">
<version>5.03.00048</version>
<version>5.03.00049</version>
<author><![CDATA[Courseplay.devTeam]]></author>
<title>
<br>CoursePlay 5</br>
Expand Down
23 changes: 14 additions & 9 deletions turn.lua
Original file line number Diff line number Diff line change
Expand Up @@ -494,15 +494,20 @@ function courseplay:turn(vehicle, dt)
courseplay:debug(("%s:(Turn) Change direction when anglediff(%.2f) <= %.2f"):format(nameNum(vehicle), angleDifference, allowedAngle), 14);
if angleDifference <= allowedAngle then
local changeToForward = newTarget.turnReverse;
for i = vehicle.cp.curTurnIndex, #vehicle.cp.turnTargets, 1 do
if changeToForward and not vehicle.cp.turnTargets[i].turnReverse then
courseplay:debug(("%s:(Turn) Changing to forward"):format(nameNum(vehicle)), 14);
vehicle.cp.curTurnIndex = i;
return;
elseif not changeToForward and vehicle.cp.turnTargets[i].turnReverse then
courseplay:debug(("%s:(Turn) Changing to reverse"):format(nameNum(vehicle)), 14);
vehicle.cp.curTurnIndex = i;
return;
if math.abs(vehicle.lastSpeedReal) > 0.0001 and vehicle.mrIsMrVehicle then
allowedToDrive = false -- This is to ensure MR brakes before changing directions to prevent runaway tractors on steep grades
else
local changeToForward = newTarget.turnReverse;
for i = vehicle.cp.curTurnIndex, #vehicle.cp.turnTargets, 1 do
if changeToForward and not vehicle.cp.turnTargets[i].turnReverse then
courseplay:debug(("%s:(Turn) Changing to forward"):format(nameNum(vehicle)), 14);
vehicle.cp.curTurnIndex = i;
return;
elseif not changeToForward and vehicle.cp.turnTargets[i].turnReverse then
courseplay:debug(("%s:(Turn) Changing to reverse"):format(nameNum(vehicle)), 14);
vehicle.cp.curTurnIndex = i;
return;
end;
end;
end;
end;
Expand Down

0 comments on commit 36eae5a

Please sign in to comment.