fix(marker): ensilage går til gæringssilo (produktion skår -> SILAGE) før almindelig silo; hø aldrig i gæringssilo (v1.25.0.0)

In-game 25/9: læssevognen aflæssede græs i en Farma-silo i stedet for en ensilage-silo.
This commit is contained in:
2026-09-25 23:43:51 +02:00
parent cf7a2a51e5
commit 7f83cc4d28
10 changed files with 86 additions and 9 deletions
+39
View File
@@ -213,9 +213,48 @@ end
-- ---- silo ----
-- Gårdens gæringssiloer for markens skår, nærmest marken først (produktioner skår -> SILAGE).
function ADFieldJobs.getFermenters(adEnv, farmId, windrowFillType, x, z)
local silage = g_fillTypeManager ~= nil and g_fillTypeManager:getFillTypeIndexByName("SILAGE") or nil
local result = {}
for _, building in ipairs(ADBuildings.list(adEnv, farmId)) do
local spec = building.kind == "factory" and building.placeable ~= nil and building.placeable.spec_productionPoint or nil
local point = spec ~= nil and spec.productionPoint or nil
if point ~= nil and ADFieldModel.isFermenter(point.productions, windrowFillType, silage) then
local bx, _, bz = getWorldTranslation(building.placeable.rootNode)
table.insert(result, {building = building, distance = (bx - (x or bx)) ^ 2 + (bz - (z or bz)) ^ 2})
end
end
table.sort(result, function(a, b) return a.distance < b.distance end)
local buildings = {}
for _, entry in ipairs(result) do table.insert(buildings, entry.building) end
return buildings
end
local function unloadMarkerIds(buildings)
local markerIds = {}
for _, building in ipairs(buildings) do
for _, marker in ipairs(ADBuildings.getMarkers(building, "unload") or {}) do
table.insert(markerIds, marker.id)
end
end
return markerIds
end
-- Tvunget lager -> de valgte; ensilage -> gæringssiloer (produktion skår -> ensilage) før almindelige
-- siloer (in-game 25/9: græs endte i en Farma-silo); hø -> kun siloer, aldrig gæringssiloer (flere af dem
-- laver også hø om til ensilage).
local function chooseStore(adEnv, field, info, vehicle)
local fillType = field.plan.product == "hay" and info.hay or info.windrow
local isReachable = function(markerId) return ADUnloadWait.hasRouteTo(adEnv, vehicle, markerId) end
if #field.plan.storeBuildingIds == 0 and field.plan.product ~= "hay" then
local fermenters = ADFieldJobs.getFermenters(adEnv, vehicle:getOwnerFarmId(), fillType, info.x, info.z)
if #fermenters > 0 then
local store, why = ADLoadSwap.findForcedDumpMarker(adEnv, vehicle, fillType, 1, unloadMarkerIds(fermenters), isReachable)
if store ~= nil then return store end
log(field.id, "ingen gæringssilo kan tage græsset (%s) — bruger almindelig silo", tostring(why))
end
end
if #field.plan.storeBuildingIds > 0 then
local markerIds = {}
for _, buildingId in ipairs(field.plan.storeBuildingIds) do
+17
View File
@@ -178,6 +178,23 @@ function ADFieldModel.collectorOffset(ownOffset, windrowOffset)
return math.max(-ADFieldModel.CP_MAX_TOOL_OFFSET, math.min(ADFieldModel.CP_MAX_TOOL_OFFSET, offset))
end
-- Gæringssilo: en produktion der har markens skår som input og ensilage som output (FermentingSiloPack,
-- GrassSilageSilo m.fl. er produktioner, ikke siloer). productions = {{inputs = {{type}}, outputs = {{type}}}}.
function ADFieldModel.isFermenter(productions, windrowFillType, silageFillType)
if silageFillType == nil then return false end
for _, production in ipairs(productions or {}) do
local takesWindrow, makesSilage = false, false
for _, input in ipairs(production.inputs or {}) do
if input.type == windrowFillType then takesWindrow = true end
end
for _, output in ipairs(production.outputs or {}) do
if output.type == silageFillType then makesSilage = true end
end
if takesWindrow and makesSilage then return true end
end
return false
end
function ADFieldModel.toRecord(field)
return {
id = field.id, stage = field.stage, mode = field.plan.mode, product = field.plan.product,
@@ -129,11 +129,17 @@ function SmartPickupFrame:fillFieldStoreRows(adEnv, info, field)
local fieldSilos = {}
for _, building in ipairs(ADFields.fieldSilos(adEnv, farmId, info)) do fieldSilos[building.id] = building end
local count = 0
local fermenterIds = {}
if field.plan.product ~= "hay" then
for _, building in ipairs(ADFieldJobs.getFermenters(adEnv, farmId, fillType, info.x, info.z)) do fermenterIds[building.id] = true end
end
for _, building in ipairs(ADBuildings.list(adEnv, farmId)) do
if building.kind == "silo" and (chosen[building.id] or ADRunsController.canStoreAt(adEnv, building, {{fillType = fillType, isPallet = false}})) then
local isSilo = building.kind == "silo" and ADRunsController.canStoreAt(adEnv, building, {{fillType = fillType, isPallet = false}})
if chosen[building.id] or isSilo or fermenterIds[building.id] then
count = count + 1
local row = self:addRow(self.ingredientPrefab, {kind = "fieldStore", buildingId = building.id})
local suffix = fieldSilos[building.id] ~= nil and (" (" .. i18n:getText("spu_field_fieldSilo") .. ")") or ""
if fermenterIds[building.id] then suffix = suffix .. " (" .. i18n:getText("spu_field_fermenter") .. ")" end
row:getDescendantByName("title"):setText(" " .. tostring(building.name) .. suffix)
row:getDescendantByName("option"):setState(chosen[building.id] and SmartPickupFrame.STATE_ON or SmartPickupFrame.STATE_OFF, false)
end
@@ -141,7 +147,7 @@ function SmartPickupFrame:fillFieldStoreRows(adEnv, info, field)
if count == 0 then
self:addTextRow(" " .. i18n:getText("spu_field_noStore"))
elseif #field.plan.storeBuildingIds == 0 then
self:addTextRow(" " .. i18n:getText("spu_field_storeAuto"))
self:addTextRow(" " .. i18n:getText(field.plan.product == "hay" and "spu_field_storeAuto" or "spu_field_storeAutoSilage"))
end
-- marksiloer skal tømmes hjem af et udkørselsflow
for id, building in pairs(fieldSilos) do
+2
View File
@@ -91,6 +91,8 @@
<text name="spu_field_side_center" text="i midten"/>
<text name="spu_field_side_left" text="til venstre"/>
<text name="spu_field_side_right" text="til højre"/>
<text name="spu_field_fermenter" text="gæringssilo"/>
<text name="spu_field_storeAutoSilage" text="intet valgt: nærmeste gæringssilo med plads, ellers nærmeste silo"/>
<text name="spu_button_start" text="Start run"/>
<text name="spu_button_stop" text="Stop run"/>
<text name="spu_button_new" text="Nyt run"/>
+2
View File
@@ -91,6 +91,8 @@
<text name="spu_field_side_center" text="in the middle"/>
<text name="spu_field_side_left" text="to the left"/>
<text name="spu_field_side_right" text="to the right"/>
<text name="spu_field_fermenter" text="fermenting silo"/>
<text name="spu_field_storeAutoSilage" text="none chosen: nearest fermenting silo with room, else nearest silo"/>
<text name="spu_button_start" text="Start run"/>
<text name="spu_button_stop" text="Stop run"/>
<text name="spu_button_new" text="New run"/>
+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.24.0.0</version>
<version>1.25.0.0</version>
<title>
<en>AD Smart Pickup</en>
</title>
+2 -2
View File
@@ -1,6 +1,6 @@
# AD Smart Pickup — brugermanual
Version 1.24.0 · Farming Simulator 25 · tillæg til AutoDrive
Version 1.25.0 · Farming Simulator 25 · tillæg til AutoDrive
*English version: [USER_MANUAL.md](USER_MANUAL.md)*
@@ -570,7 +570,7 @@ Klik på en mark i tabellen for at vælge den. Under tabellen står:
| **Plan** | Ensilage eller Hø |
| **Kørsel** | *Manuel*: marken venter på **Start nu**. *Auto*: marken starter selv, når den er klar |
| **Riv** | Riv skårene sammen før opsamling (hø og ensilage). Standard fra. Slå til ved smalle læssevogne |
| **Tving lager** | Vælg siloer. Uden valg bruges nærmeste silo med plads, der tager varen |
| **Tving lager** | Vælg lagre. Uden valg: **ensilage** går til nærmeste **gæringssilo** (en produktion der laver skår om til ensilage, fx FermentingSiloPack) med plads, ellers nærmeste silo. **Hø** går kun i almindelige siloer, aldrig i en gæringssilo |
En mark er **klar**, når mindst 90 % af den står i høstvinduet. Status viser andelen, fx `Venter 72 %`.
**Start nu** virker fra 50 %. **Stop mark** stopper maskinerne på marken, og marken står klar igen.
+2 -2
View File
@@ -1,6 +1,6 @@
# AD Smart Pickup — user manual
Version 1.24.0 · Farming Simulator 25 · add-on for AutoDrive
Version 1.25.0 · Farming Simulator 25 · add-on for AutoDrive
*Dansk version: [BRUGERMANUAL.md](BRUGERMANUAL.md)*
@@ -577,7 +577,7 @@ Click a field in the table to select it. Below the table:
| **Plan** | Silage or Hay |
| **Mode** | *Manual*: the field waits for **Start now**. *Auto*: the field starts by itself when ready |
| **Rake** | Rake the swaths before collecting (hay and silage). Off by default. Turn on for narrow loading wagons |
| **Force storage** | Pick silos. Without a choice the nearest silo with room that takes the goods is used |
| **Force storage** | Pick stores. Without a choice: **silage** goes to the nearest **fermenting silo** (a production that turns swaths into silage, such as FermentingSiloPack) with room, else the nearest silo. **Hay** only goes to ordinary silos, never a fermenting silo |
A field is **ready** when at least 90 % of it is in the harvest window. The status shows the share,
such as `Waiting 72 %`. **Start now** works from 50 %. **Stop field** stops the machines on the field,
@@ -52,8 +52,10 @@ Ikke med i etape 1: mejetærskerafgrøder (etape 2), roer (etape 3), jordbehandl
`dropWindrowWorkAreaIndex`, ellers riverens XML) i traktorens ramme minus rivens CP-forskydning =
skårets sideforskydning (gemt pr. mark). Læssevognen på rivens kursus får `toolOffsetX = egen −
skårets` (±10 m) og får sin egen værdi tilbage bagefter.
7. **Silovalg** genbruger Smart Pickups motor (`ADLoadSwap`): nærmeste silo med plads, der tager varen,
med vej fra `F`-markøren. *Tving lager* pr. mark (som "Lager til" i flows). Fabrikker er ikke mål.
7. **Silovalg** genbruger Smart Pickups motor (`ADLoadSwap`). *Tving lager* pr. mark (som "Lager til" i
flows). **Revideret 25/9:** ensilage går først til egne **gæringssiloer** (produktion skår -> SILAGE,
fx FermentingSiloPack/GrassSilageSilo), nærmest marken, ellers nærmeste silo med plads; hø kun til
almindelige siloer (gæringssiloer laver også hø om til ensilage).
8. **Marksilo.** En silo, hvis afstand til markens polygon er ≤ 150 m, er et mellemlager. Den må gerne
vælges (korte ture). Oversigten viser "!" ved marken, hvis intet Smart Pickup-udkørselsflow har
siloen som kilde — hjemkørslen klares af de eksisterende flows, ikke af markdelen.
+9
View File
@@ -133,5 +133,14 @@ check("M12 skår gemt", M.fromRecord(M.toRecord(side)).windrowOffset, 3.2)
check("M12 intet skår gemt", M.fromRecord(M.toRecord(M.newField(12))).windrowOffset, nil)
check("M12 start glemmer skår", M.start(M.with(M.onReadiness(M.newField(13), 1), {windrowOffset = 1})).windrowOffset, nil)
-- M13: gæringssilo = produktion der laver markens skår om til ensilage (FermentingSiloPack m.fl.)
local GRASS_W, DRY_W, SILAGE, CHAFF, BREAD = 10, 11, 20, 30, 40
local fermenter = {{inputs = {{type = CHAFF}}, outputs = {{type = SILAGE}}}, {inputs = {{type = GRASS_W}}, outputs = {{type = SILAGE}}}}
check("M13 græs -> ensilage", M.isFermenter(fermenter, GRASS_W, SILAGE), true)
check("M13 hø ikke i denne", M.isFermenter(fermenter, DRY_W, SILAGE), false)
check("M13 bageri ikke", M.isFermenter({{inputs = {{type = GRASS_W}}, outputs = {{type = BREAD}}}}, GRASS_W, SILAGE), false)
check("M13 ingen produktioner", M.isFermenter(nil, GRASS_W, SILAGE), false)
check("M13 ukendt ensilage-type", M.isFermenter(fermenter, GRASS_W, nil), false)
print(failures == 0 and "\nALLE TESTS OK" or ("\n" .. failures .. " FEJL"))
os.exit(failures == 0 and 0 or 1)