feat: intet græsarbejde om vinteren; stillestående opsamler stoppes (v1.62.71)

This commit is contained in:
2026-10-07 23:59:29 +02:00
parent 0e07651532
commit f0204d72a7
7 changed files with 51 additions and 2 deletions
+13 -1
View File
@@ -216,11 +216,13 @@ end
function ADFieldJobs.decide(field, info, assignments, now, env)
local hasMarker = info ~= nil and info.markerId ~= nil
local raining = env ~= nil and env.raining == true
local period = env ~= nil and env.period or nil
local kind = field.kind or (info ~= nil and info.kind) or "mowable"
if field.stage == "ready" then
if not ADFieldModel.shouldStart(field) then return {action = "none"} end
if not hasMarker then return {action = "wait"} end
local first = ADFieldModel.workStages(field.plan, info.kind, info.needs)[1]
if ADFieldModel.isOutOfSeason(first, period) then return {action = "wait", reason = "winter"} end
if raining and first ~= nil and ADFieldModel.isWeatherSensitive(first, field.plan, info.kind) then
return {action = "wait", reason = "rain"}
end
@@ -281,6 +283,7 @@ function ADFieldJobs.decide(field, info, assignments, now, env)
end
if not hasMarker then return {action = "wait"} end
if (field.retryAt or 0) > now then return {action = "none"} end
if ADFieldModel.isOutOfSeason(field.stage, period) then return {action = "wait", reason = "winter"} end
if raining and ADFieldModel.isWeatherSensitive(field.stage, field.plan, kind) then
return {action = "wait", reason = "rain"}
end
@@ -453,14 +456,23 @@ function ADFieldJobs.notify(text, critical)
end)
end
-- Vejret lige nu (regn), læst en gang pr. tick.
-- Opsamler der står stille med Courseplay aktiv uden at blive fyldt så længe, har intet at samle op (in-game 7/10:
-- F13's læssevogne stod stille i januar efter genindlæsning, og marken stod som "kører").
ADFieldJobs.COLLECTOR_STALL_MS = 3 * 60 * 1000
function ADFieldJobs.collectorStalled(s)
return s.role == "collector" and type(s.stillMs) == "number" and s.stillMs >= ADFieldJobs.COLLECTOR_STALL_MS
end
-- Vejret lige nu (regn) og årets periode, læst en gang pr. tick.
function ADFieldJobs.environment()
local ok, raining = pcall(function()
local weather = g_currentMission.environment.weather
return weather ~= nil and weather.getIsRaining ~= nil and weather:getIsRaining() or false
end)
local okPeriod, period = pcall(function() return g_currentMission.environment.currentPeriod end)
return {
raining = ok and raining == true,
period = okPeriod and type(period) == "number" and period or nil,
-- kan afgrøden (navn) sås i den aktuelle periode?
plantable = function(name)
local fruit = g_fruitTypeManager ~= nil and g_fruitTypeManager:getFruitTypeByName(name) or nil
+8
View File
@@ -341,6 +341,14 @@ end
-- Vejrfølsomme trin: afgrøde og skår skal være tørre (høst, slåning, vending, rivning, hø-opsamling).
-- Jordbehandling, såning, pleje og ensilage-opsamling kan køre i regn.
local WEATHER_STAGES = {harvesting = true, mowing = true, tedding = true, raking = true, strawCollecting = true, baling = true}
-- Vinter: FS25-periode 10-12 = december-februar (periode 1 = marts). Græs gror ikke, så græsarbejde (slå, vende, rive)
-- startes ikke; opsamling af skår der allerede ligger må gerne (in-game 7/10: opsamlere stod stille på F13 i januar).
ADFieldModel.WINTER_PERIODS = {[10] = true, [11] = true, [12] = true}
ADFieldModel.WINTER_BLOCKED_STAGES = {mowing = true, tedding = true, raking = true}
function ADFieldModel.isOutOfSeason(stage, period)
return ADFieldModel.WINTER_PERIODS[period] == true and ADFieldModel.WINTER_BLOCKED_STAGES[stage] == true
end
function ADFieldModel.isWeatherSensitive(stage, plan, kind)
if WEATHER_STAGES[stage] then return true end
return stage == "collecting" and ADFieldModel.product(plan, kind or "mowable") == "hay"
+24
View File
@@ -1272,6 +1272,18 @@ local function followManual(adEnv, field, info, assignment)
end
end
-- Opsamleren står stille med Courseplay aktiv og fyldes ikke: tæl tiden (bevægelse eller mere last nulstiller).
local function collectorStillMs(adEnv, assignment, vehicle)
local speed = vehicle.getLastSpeed ~= nil and vehicle:getLastSpeed() or 0
local fill = restLoad(adEnv, vehicle) or 0
if speed > 0.5 or fill > (assignment.stallFill or -1) + 1 then
assignment.stallSince, assignment.stallFill = nil, fill
return 0
end
assignment.stallSince = assignment.stallSince or now()
return now() - assignment.stallSince
end
local function followWorking(adEnv, field, assignment)
local vehicle = assignment.vehicle
if assignment.role == "rake" and field.windrowOffset == nil and now() - assignment.since >= ADFieldWork.WINDROW_MEASURE_MS
@@ -1283,6 +1295,18 @@ local function followWorking(adEnv, field, assignment)
if ADCpBridge.isWorking(vehicle) or isAdActive(vehicle) then
assignment.idleSince = nil
assignment.seenWorking = true
if assignment.role == "collector" and ADCpBridge.isWorking(vehicle) then
local okStill, stillMs = pcall(collectorStillMs, adEnv, assignment, vehicle)
if okStill and ADFieldJobs.collectorStalled({role = assignment.role, stillMs = stillMs}) then
-- intet at samle op: stop CP; næste tik afslutter som færdig (rest til lager, marken videre)
assignment.stallSince = nil
pcall(ADCpBridge.stop, vehicle)
local text = string.format("'%s' stod stille i %d min uden at samle noget op — opsamlingen stoppes",
ADRuns.vehicleLabel(vehicle), math.floor(ADFieldJobs.COLLECTOR_STALL_MS / 60000))
log(assignment.fieldId, "%s", text)
ADFieldJobs.notify(string.format("F%s: %s", tostring(assignment.fieldId), text), true)
end
end
return
end
-- genoptaget efter indlæsning: CP starter asynkront — vent til den kører, før "står stille" betyder færdig
+2
View File
@@ -86,6 +86,7 @@
<text name="spu_field_reasonShort_notPlantable" text="ikke såtid nu"/>
<text name="spu_field_reasonShort_regrowing" text="venter på genvækst"/>
<text name="spu_field_reasonShort_rain" text="venter på tørvejr"/>
<text name="spu_field_reasonShort_winter" text="vinter"/>
<text name="spu_field_reasonShort_text" text="se detaljer"/>
<text name="spu_field_reason_allBusy" text="venter på ledig %s"/>
<text name="spu_pool_section_tractors" text="Maskinpulje — traktorer (henter redskaber når ingen færdig kombination er ledig)"/>
@@ -225,6 +226,7 @@
<text name="spu_field_notice_done" text="er færdig"/>
<text name="spu_field_reason_regrowing" text="venter på at græsset vokser helt ud igen"/>
<text name="spu_field_reason_rain" text="venter på tørvejr"/>
<text name="spu_field_reason_winter" text="venter — vinter, græsset gror ikke"/>
<text name="spu_field_target" text="Afgrøde på marken (moden passer resten)"/>
<text name="spu_field_target_none" text="Ingen — planlæg selv"/>
<text name="spu_field_target_bare" text="Klargøres og tilsås med %s, så snart det er såtid"/>
+2
View File
@@ -86,6 +86,7 @@
<text name="spu_field_reasonShort_notPlantable" text="not sowing time"/>
<text name="spu_field_reasonShort_regrowing" text="waiting for regrowth"/>
<text name="spu_field_reasonShort_rain" text="waiting for dry weather"/>
<text name="spu_field_reasonShort_winter" text="winter"/>
<text name="spu_field_reasonShort_text" text="see details"/>
<text name="spu_field_reason_allBusy" text="waiting for a free %s"/>
<text name="spu_pool_section_tractors" text="Machine pool — tractors (fetch implements when no ready combination is free)"/>
@@ -225,6 +226,7 @@
<text name="spu_field_notice_done" text="is done"/>
<text name="spu_field_reason_regrowing" text="waiting for the regrowth to reach full height"/>
<text name="spu_field_reason_rain" text="waiting for dry weather"/>
<text name="spu_field_reason_winter" text="waiting — winter, grass does not grow"/>
<text name="spu_field_target" text="Crop on the field (the mod handles the rest)"/>
<text name="spu_field_target_none" text="None — plan it yourself"/>
<text name="spu_field_target_bare" text="Prepared and sown with %s as soon as it is sowing time"/>
+1 -1
View File
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<modDesc descVersion="107">
<author>masterdraco</author>
<version>1.62.70.0</version>
<version>1.62.71.0</version>
<title>
<en>AD Smart Pickup</en>
</title>