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

Commit

Permalink
0433: mode2: fix frontTractor following
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakob Tischler committed Mar 15, 2014
1 parent 2c7271b commit a9c8986
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
1 change: 1 addition & 0 deletions combines.lua
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ function courseplay:register_at_combine(self, combine)
local frontTractor = combine.courseplayers[numAllowedCourseplayers - 1];
if frontTractor then
local canFollowFrontTractor = frontTractor.cp.tipperFillLevelPct and frontTractor.cp.tipperFillLevelPct >= self.cp.followAtFillLevel;
courseplay:debug(string.format('%s: frontTractor (%s) fillLevelPct (%.1f), my followAtFillLevel=%d -> canFollowFrontTractor=%s', nameNum(self), nameNum(frontTractor), frontTractor.cp.tipperFillLevelPct, self.cp.followAtFillLevel, tostring(canFollowFrontTractor)), 4)
if not canFollowFrontTractor then
return false;
end;
Expand Down
3 changes: 1 addition & 2 deletions courseplay.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ end;

courseplay.sonOfaBangSonOfaBoom = {
['44d143f3e847254a55835a8298ba4e21'] = true;
['87a96c3bb39fa285d7ed2fb5beaffc16'] = true;
['87a96c3bb39fa285d7ed2fb5beaffc16'] = true;
};
courseplay.isDeveloper = courseplay.sonOfaBangSonOfaBoom[getMD5(g_settingsNickname)];
if courseplay.isDeveloper then
Expand Down Expand Up @@ -97,7 +97,6 @@ function courseplay:initialize()
'courseplay_event',
'courseplay_manager',
'course_management',
'creatingAndDeletingFolders',
'debug',
'distance',
'drive',
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="13">
<version>3.41.0432</version>
<version>3.41.0433</version>
<author><![CDATA[Jakob Tischler, Thomas Gärtner,
Horoman]]></author>
<title>
Expand Down
14 changes: 9 additions & 5 deletions mode2.lua
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ function courseplay:handle_mode2(self, dt)
else
-- follow tractor in front of me
frontTractor = self.cp.activeCombine.courseplayers[self.cp.positionWithCombine - 1]
-- print(string.format('%s: activeCombine ~= nil, my position=%d, frontTractor (positionWithCombine %d) = %q', nameNum(self), self.cp.positionWithCombine, self.cp.positionWithCombine - 1, nameNum(frontTractor)));
courseplay:debug(string.format('%s: activeCombine ~= nil, my position=%d, frontTractor (positionWithCombine %d) = %q', nameNum(self), self.cp.positionWithCombine, self.cp.positionWithCombine - 1, nameNum(frontTractor)), 4);
-- courseplay:follow_tractor(self, dt, tractor)
self.cp.modeState = 6
courseplay:unload_combine(self, dt)
Expand Down Expand Up @@ -162,7 +162,7 @@ function courseplay:handle_mode2(self, dt)


local highest_fill_level = 0;
local num_courseplayers = 0;
local num_courseplayers = 0; --TODO: = fewest courseplayers ?
local distance = 0;

self.best_combine = nil;
Expand All @@ -182,7 +182,7 @@ function courseplay:handle_mode2(self, dt)
if numCombineCourseplayers > 0 then
frontTractor = combine.courseplayers[num_courseplayers];
local canFollowFrontTractor = frontTractor.cp.tipperFillLevelPct and frontTractor.cp.tipperFillLevelPct >= self.cp.followAtFillLevel;
-- print(string.format('frontTractor (pos %d)=%q, canFollowFrontTractor=%s', numCombineCourseplayers, nameNum(frontTractor), tostring(canFollowFrontTractor)));
courseplay:debug(string.format('%s: frontTractor (pos %d)=%q, canFollowFrontTractor=%s', nameNum(self), numCombineCourseplayers, nameNum(frontTractor), tostring(canFollowFrontTractor)), 4);
if canFollowFrontTractor then
self.best_combine = combine
end
Expand Down Expand Up @@ -895,10 +895,14 @@ function courseplay:unload_combine(self, dt)
end
end

local frontTractor;
if self.cp.activeCombine and self.cp.activeCombine.courseplayers and self.cp.positionWithCombine then
frontTractor = self.cp.activeCombine.courseplayers[self.cp.positionWithCombine - 1];
end;
if self.cp.modeState == 6 and frontTractor ~= nil then --Follow Tractor
self.cp.infoText = courseplay:loc("CPFollowTractor") -- "Fahre hinter Traktor"
--use the current tractor's sideToDrive as own
if frontTractor.sideToDrive ~= nil then
if frontTractor.sideToDrive ~= nil and frontTractor.sideToDrive ~= self.sideToDrive then
courseplay:debug(string.format("%s: setting current tractor's sideToDrive (%s) as my own", nameNum(self), tostring(frontTractor.sideToDrive)), 4);
self.sideToDrive = frontTractor.sideToDrive;
end;
Expand Down Expand Up @@ -936,7 +940,7 @@ function courseplay:unload_combine(self, dt)
dod = Utils.vector2Length(lx, lz)
-- if dod < 2 or (self.cp.positionWithCombine == 2 and frontTractor.cp.modeState ~= 3 and dod < 100) then
if dod < 2 or (self.cp.positionWithCombine == 2 and combine.courseplayers[1].cp.modeState ~= 3 and dod < 100) then
-- print(string.format('\tdod=%s, frontTractor.cp.modeState=%s -> brakeToStop', tostring(dod), tostring(frontTractor.cp.modeState)));
courseplay:debug(string.format('\tdod=%s, frontTractor.cp.modeState=%s -> brakeToStop', tostring(dod), tostring(frontTractor.cp.modeState)), 4);
allowedToDrive = courseplay:brakeToStop(self)
end
if combine.cp.isSugarBeetLoader then
Expand Down

0 comments on commit a9c8986

Please sign in to comment.