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>