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

set private Development up to date #2

Merged
merged 8 commits into from
Feb 19, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion combines.lua
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ function courseplay:register_at_combine(self, combine)
end

if table.getn(combine.courseplayers) == num_allowed_courseplayers then
courseplay:debug(tostring(self.id).." : combine: "..tostring(combine.id).. "is already registered ", 1)
return false
end

Expand All @@ -148,7 +149,7 @@ function courseplay:register_at_combine(self, combine)
local vehicle_ID = 0
for k, vehicle in pairs(g_currentMission.vehicles) do --TODO: Liste einengen, nur Courseplayers
if vehicle.combineID ~= nil then
if vehicle.combineID == combine.id then
if vehicle.combineID == combine.id and vehicle.active_combine == nil then
courseplay:debug(tostring(vehicle.id).." : distanceToCombine:"..tostring(vehicle.distanceToCombine).." for combine.id:"..tostring(combine.id), 1)
if distance > vehicle.distanceToCombine then
distance = vehicle.distanceToCombine
Expand Down
4 changes: 3 additions & 1 deletion drive.lua
Original file line number Diff line number Diff line change
Expand Up @@ -432,17 +432,19 @@ function courseplay:drive(self, dt)

-- Mode 6 Fieldwork for balers and foragewagon
if self.ai_mode == 6 and self.startWork ~= nil and self.stopWork ~= nil then
allowedToDrive, workArea, workSpeed, active_tipper = courseplay:handle_mode6(self, allowedToDrive, workArea, workSpeed, fill_level, last_recordnumber)
if not workArea and self.aiTrafficCollisionTrigger ~= nil and self.grainTankCapacity == nil then
-- is there a tipTrigger within 10 meters?

raycastAll(tx, ty, tz, nx, ny, nz, "findTipTriggerCallback", 10, self)
if self.currentTipTrigger == nil then

raycastAll(tx+self.tipRefOffset, ty, tz, nx, ny, nz, "findTipTriggerCallback", 10, self)
end
if self.currentTipTrigger == nil then
raycastAll(tx-self.tipRefOffset, ty, tz, nx, ny, nz, "findTipTriggerCallback", 10, self)
end
end;
allowedToDrive, workArea, workSpeed, active_tipper = courseplay:handle_mode6(self, allowedToDrive, workArea, workSpeed, fill_level, last_recordnumber)
end


Expand Down
20 changes: 9 additions & 11 deletions mode2.lua
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ function courseplay:handle_mode2(self, dt)
if self.reachable_combines ~= nil then
if table.getn(self.reachable_combines) > 0 then
-- choose the combine that needs me the most
if self.best_combine ~= nil then
if self.best_combine ~= nil and self.active_combine == nil then
courseplay:debug(tostring(self.id)..": request check in: "..tostring(self.combineID), 1)
if courseplay:register_at_combine(self, self.best_combine) then
local leftFruit, rightFruit = courseplay:side_to_drive(self, self.best_combine, -10) --changed by THOMAS
Expand Down Expand Up @@ -285,9 +285,9 @@ function courseplay:unload_combine(self, dt)

if z1 > -10 then -- tractor in front of combine --0
-- left side of combine
local cx_left, cy_left, cz_left = localToWorld(combine.rootNode, 20, 0, -20) --20,0, -30 (war 20,0,-25
local cx_left, cy_left, cz_left = localToWorld(combine.rootNode, 20, 0, -30) --20,0, -30 (war 20,0,-25
-- righ side of combine
local cx_right, cy_right, cz_right = localToWorld(combine.rootNode, -20, 0, -20) -- -20,0,-30 -20,0,-25
local cx_right, cy_right, cz_right = localToWorld(combine.rootNode, -20, 0, -30) -- -20,0,-30 -20,0,-25
local lx, ly, lz = worldToLocal(self.aiTractorDirectionNode, cx_left, y, cz_left)
-- distance to left position
local disL = Utils.vector2Length(lx, lz)
Expand All @@ -303,7 +303,7 @@ function courseplay:unload_combine(self, dt)

else
-- tractor behind combine
currentX, currentY, currentZ = localToWorld(combine.rootNode, 0, 0, -25)
currentX, currentY, currentZ = localToWorld(combine.rootNode, 0, 0, -35) -- -25
end

--if not self.calculated_course then
Expand Down Expand Up @@ -629,7 +629,7 @@ function courseplay:unload_combine(self, dt)
end

-- combine is not moving and trailer is under pipe
if not cornChopper and ((combine.movingDirection == 0 and lz <= 0.5) or lz < -0.1 * trailer_offset) then
if not cornChopper and combine.movingDirection == 0 and (lz <= 1 or lz < -0.1 * trailer_offset) then
self.info_text = courseplay:get_locale(self, "CPCombineWantsMeToStop") -- "Drescher sagt ich soll anhalten."
allowedToDrive = false
elseif cornChopper then
Expand Down Expand Up @@ -681,10 +681,7 @@ function courseplay:unload_combine(self, dt)
else
refSpeed = combine_speed
end
if combine.movingDirection == 0 then
refSpeed = self.field_speed * 1.5
end
if (combine.turnStage ~= 0 and lz < 20) or self.timer < self.drive_slow_timer then
if (combine.turnStage ~= 0 and lz < 20) or (self.timer < self.drive_slow_timer) or (combine.movingDirection == 0 and lz < 15) then
refSpeed = 4 / 3600
self.sl = 1
if self.ESLimiter == nil then
Expand Down Expand Up @@ -973,9 +970,10 @@ function courseplay:unload_combine(self, dt)
end

-- check traffic and calculate speed

allowedToDrive = courseplay:check_traffic(self, true, allowedToDrive)

if allowedToDrive then

allowedToDrive = courseplay:check_traffic(self, true, allowedToDrive)
if self.sl == nil then
self.sl = 3
end
Expand Down
5 changes: 4 additions & 1 deletion mode6.lua
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,9 @@ function courseplay:handle_mode6(self, allowedToDrive, workArea, workSpeed, fill
-- Begin Work
if last_recordnumber == self.startWork and fill_level ~= 100 then
if self.abortWork ~= nil then
if self.abortWork < 5 then
self.abortWork = 6
end
self.recordnumber = self.abortWork - 4
if self.recordnumber < 1 then
self.recordnumber = 1
Expand All @@ -232,7 +235,7 @@ function courseplay:handle_mode6(self, allowedToDrive, workArea, workSpeed, fill
end
-- safe last point
if (fill_level == 100 or self.loaded) and workArea and self.abortWork == nil and self.maxnumber ~= self.stopWork then
self.abortWork = self.recordnumber
self.abortWork = self.recordnumber -4
self.recordnumber = self.stopWork - 4
if self.recordnumber < 1 then
self.recordnumber = 1
Expand Down
21 changes: 17 additions & 4 deletions tippers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ function courseplay:unload_tippers(self)
for k, tipper in pairs(self.tippers) do
--if not tipper.allowsDetaching then
local numReferencePoints = table.getn(tipper.tipReferencePoints);
local fruitType = tipper:getCurrentFruitType()
local fruitType = tipper.currentFillType

if self.currentTipTrigger.bunkerSilo ~= nil then

Expand Down Expand Up @@ -388,7 +388,8 @@ function courseplay:getAutoTurnradius(self, tipper_attached)
local sinAlpha = 0 --Sinus vom Lenkwinkel
local wheelbase = 0 --Radstand
local track = 0 --Spurweite
local turnRadius --Wendekreis unbereinigt
local turnRadius = 0 --Wendekreis unbereinigt
local xerion = false
if self.foundWheels == nil then
self.foundWheels = {}
end
Expand All @@ -400,16 +401,28 @@ function courseplay:getAutoTurnradius(self, tipper_attached)
self.foundWheels[1] = wheel
elseif self.foundWheels[2] == nil then
self.foundWheels[2] = wheel
elseif self.foundWheels[4] == nil then
self.foundWheels[4] = wheel
end
elseif self.foundWheels[3] == nil then
self.foundWheels[3] = wheel
end

end
if table.getn(self.foundWheels) == 3 then
if self.foundWheels[3] == nil then --Xerion and Co
sinAlpha = sinAlpha *2
xerion = true
end

if table.getn(self.foundWheels) == 3 or xerion then
local wh1X, wh1Y, wh1Z = getWorldTranslation(self.foundWheels[1].driveNode);
local wh2X, wh2Y, wh2Z = getWorldTranslation(self.foundWheels[2].driveNode);
local wh3X, wh3Y, wh3Z = getWorldTranslation(self.foundWheels[3].driveNode);
local wh3X, wh3Y, wh3Z = 0,0,0
if xerion then
wh3X, wh3Y, wh3Z = getWorldTranslation(self.foundWheels[4].driveNode);
else
wh3X, wh3Y, wh3Z = getWorldTranslation(self.foundWheels[3].driveNode);
end
track = courseplay:distance(wh1X, wh1Z, wh2X, wh2Z)
wheelbase = courseplay:distance(wh1X, wh1Z, wh3X, wh3Z)
turnRadius = 2*wheelbase/sinAlpha+track
Expand Down
2 changes: 1 addition & 1 deletion triggers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function courseplay:findTipTriggerCallback(transformId, x, y, z, distance)
local tipper_fill_level, tipper_capacity = self:getAttachedTrailersFillLevelAndCapacity()
if trigger.triggerId ~= nil and trigger.triggerId == transformId and (trigger.bunkerSilo == nil or (trigger.bunkerSilo.fillLevel + tipper_capacity) < trigger.bunkerSilo.capacity) then
courseplay:debug(table.show(trigger), 4);
local fruitType = self.tippers[1]:getCurrentFruitType()
local fruitType = self.tippers[1].currentFillType

if trigger.acceptedFillTypes[fruitType] then
self.currentTipTrigger = trigger
Expand Down