feat(bomuld): balleopsamling slutter først når modulerne er samlet op (v1.62.270)
This commit is contained in:
@@ -14,6 +14,8 @@ ADFieldJobs.SLOW_TICK_MS = 3
|
||||
ADFieldJobs.tickCount = 0
|
||||
-- Courseplay kan efterlade hjørner på skæve marker: efter så mange færdige ture pr. sæt går marken videre.
|
||||
ADFieldJobs.MAX_PASSES = 2
|
||||
-- balleopsamling med baller tilbage: så mange færdige ballesamler-ture før marken går videre alligevel
|
||||
ADFieldJobs.MAX_BALE_PASSES = 5
|
||||
-- fleetMode: "all" = alle ledige maskiner (standard, "vælg og glem"), "ticked" = kun med flueben
|
||||
-- courseRecords: vehicleId -> post i kursus-registret (ADCourseCache)
|
||||
-- manual: {[vehicleId] = true} = høstere spilleren selv kører til marken (for brede til vejene)
|
||||
@@ -464,7 +466,13 @@ function ADFieldJobs.decide(field, info, assignments, now, env)
|
||||
if groundKey ~= nil and info ~= nil and type(info[groundKey]) == "number" and info[groundKey] >= ADFieldJobs.PREPARED_DONE_RATIO then
|
||||
return {action = "advance"}
|
||||
end
|
||||
if finished > 0 then
|
||||
-- balleopsamling med optalte baller (bomuldsmoduler): videre først når marken er tom — eller efter
|
||||
-- MAX_BALE_PASSES forsøg, så marken ikke låses af moduler ingen opsamler kan tage (brugerønske 16/10)
|
||||
local balesLeft = info ~= nil and info.balesLeft or nil
|
||||
if field.stage == "baleCollecting" and balesLeft ~= nil then
|
||||
if balesLeft == 0 then return {action = "advance"} end
|
||||
if finished >= ADFieldJobs.MAX_BALE_PASSES then return {action = "advance", balesLeft = balesLeft} end
|
||||
elseif finished > 0 then
|
||||
local maxPasses = ADFieldJobs.MAX_PASSES * ADFieldModel.maxRigs(field.stage, field.plan)
|
||||
if not isCropStage or finished >= maxPasses then return {action = "advance"} end
|
||||
end
|
||||
@@ -712,6 +720,17 @@ local function stepField(adEnv, info, env)
|
||||
if ADFieldWork ~= nil and ADFieldWork.tripPlaceholders ~= nil then
|
||||
for _, pending in ipairs(ADFieldWork.tripPlaceholders(info.id)) do table.insert(assignments, pending) end
|
||||
end
|
||||
-- balleopsamling efter ballehøst: tæl de baller der stadig ligger på marken (kopi af info — cachen røres ikke)
|
||||
if field.stage == "baleCollecting" and ADFieldModel.isBaleHarvest(field.lastFruit) and ADFieldWork ~= nil
|
||||
and ADFieldWork.countFieldBales ~= nil then
|
||||
local okCount, count = pcall(ADFieldWork.countFieldBales, info, field.lastFruit)
|
||||
if okCount and type(count) == "number" then
|
||||
local copy = {}
|
||||
for key, value in pairs(info) do copy[key] = value end
|
||||
copy.balesLeft = count
|
||||
info = copy
|
||||
end
|
||||
end
|
||||
local decision = ADFieldJobs.decide(field, info, assignments, ADFieldJobs.now, env)
|
||||
ADFieldJobs.lastDecision[info.id] = decision
|
||||
if decision.action == "start" then
|
||||
@@ -734,6 +753,12 @@ local function stepField(adEnv, info, env)
|
||||
ADFieldJobs.log(info.id, "pleje: %s", decision.stage)
|
||||
ADFieldJobs.save()
|
||||
elseif decision.action == "advance" then
|
||||
if (decision.balesLeft or 0) > 0 then
|
||||
local text = string.format("F%s: %d baller ligger stadig på marken efter %d opsamlinger — saml dem selv",
|
||||
tostring(info.id), decision.balesLeft, ADFieldJobs.MAX_BALE_PASSES)
|
||||
ADFieldJobs.log(info.id, "%s", text)
|
||||
ADFieldJobs.notify(text, true)
|
||||
end
|
||||
-- høsteren har stadig korn i tanken: CP genstartes og venter ved kursets ende, tømmevognene kommer
|
||||
-- (marken bliver på høst til tanken er tom) — in-game 27/9 F15
|
||||
if field.stage == "harvesting" and ADFieldWork.tryEmptyHarvester ~= nil then
|
||||
|
||||
@@ -629,6 +629,41 @@ function ADFieldWork.seedsRefillable(adEnv, vehicle, x, z)
|
||||
return ok and result == true
|
||||
end
|
||||
|
||||
-- Ren: hvor mange af ballerne ligger løst (ikke på en vogn) inden for markens polygon med varen?
|
||||
-- bales = {{x, z, fillType, mounted}}
|
||||
function ADFieldWork.countBalesIn(bales, verts, fillType)
|
||||
local count = 0
|
||||
if #(verts or {}) < 3 then return 0 end
|
||||
for _, bale in ipairs(bales or {}) do
|
||||
if not bale.mounted and bale.fillType == fillType and ADFieldJobs.insidePolygon(bale.x, bale.z, verts) then
|
||||
count = count + 1
|
||||
end
|
||||
end
|
||||
return count
|
||||
end
|
||||
|
||||
-- Baller med afgrødens vare på marken (spillets balleliste, som Courseplays ballefinder). nil = kan ikke tælles.
|
||||
function ADFieldWork.countFieldBales(info, fruit)
|
||||
if info == nil or #(info.verts or {}) < 3 or g_currentMission == nil or g_currentMission.slotSystem == nil
|
||||
or SlotSystem == nil or g_fillTypeManager == nil then return nil end
|
||||
local fillType = g_fillTypeManager:getFillTypeIndexByName(string.upper(tostring(fruit)))
|
||||
local limits = g_currentMission.slotSystem.objectLimits
|
||||
local list = limits ~= nil and limits[SlotSystem.LIMITED_OBJECT_BALE] ~= nil and limits[SlotSystem.LIMITED_OBJECT_BALE].objects or nil
|
||||
if fillType == nil or list == nil then return nil end
|
||||
local bales = {}
|
||||
for _, object in pairs(list) do
|
||||
-- varen først (billigt), så positionen; på en vogn/stropper/autoload = ikke løs (som Courseplays isLoaded)
|
||||
if object.getFillType ~= nil and object:getFillType() == fillType and object.nodeId ~= nil and object.nodeId ~= 0
|
||||
and entityExists(object.nodeId) then
|
||||
local x, _, z = getWorldTranslation(object.nodeId)
|
||||
table.insert(bales, {x = x, z = z, fillType = fillType,
|
||||
mounted = object.mountObject ~= nil or object.dynamicMountObject ~= nil or object.tensionMountObject ~= nil
|
||||
or object.currentlyLoadedOnAPalletAutoLoaderId ~= nil})
|
||||
end
|
||||
end
|
||||
return ADFieldWork.countBalesIn(bales, info.verts, fillType)
|
||||
end
|
||||
|
||||
-- Ballelasterens fyldtyper for en ballehøst-afgrøde: {SQUAREBALE_COTTON, ROUNDBALE_COTTON} som indeks (de findes).
|
||||
function ADFieldWork.baleFillTypes(fruit)
|
||||
local result = {}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||
<modDesc descVersion="107">
|
||||
<author>masterdraco</author>
|
||||
<version>1.62.269.0</version>
|
||||
<version>1.62.270.0</version>
|
||||
<title>
|
||||
<en>AD Smart Pickup</en>
|
||||
</title>
|
||||
|
||||
Reference in New Issue
Block a user