From c5da46e87610932af9d91d169540f8fac25d4e9b Mon Sep 17 00:00:00 2001 From: masterdraco Date: Wed, 7 Oct 2026 23:24:55 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20regel=20'Hent=20f=C3=B8rst=20n=C3=A5r?= =?UTF-8?q?=20kilden=20er=20over=20X=20%'=20for=20salgsflows=20(v1.62.68)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + FS25_ADSmartPickup/adFlowGuide.lua | 14 ++++++++++++-- FS25_ADSmartPickup/adOutbound.lua | 1 + FS25_ADSmartPickup/adOutboundPlanner.lua | 8 +++++++- FS25_ADSmartPickup/adRuns.lua | 7 +++++++ FS25_ADSmartPickup/adRunsStorage.lua | 2 ++ FS25_ADSmartPickup/l10n/l10n_da.xml | 3 +++ FS25_ADSmartPickup/l10n/l10n_en.xml | 3 +++ FS25_ADSmartPickup/modDesc.xml | 2 +- docs/BRUGERMANUAL.md | 3 ++- docs/USER_MANUAL.md | 3 ++- 11 files changed, 41 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f0d488..4b658d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ står i [docs/BRUGERMANUAL.md](docs/BRUGERMANUAL.md) (dansk) og [docs/USER_MANUA ## 1.62 — Kæder slås selv til +- **1.62.68** Nyt: reglen "Hent først når kilden er over" (udkørsel med salg). Et salg venter, til den fyldeste kilde er mindst X % fuld (10–90 %), eller til et fuldt læs ligger klar. Standard er *Fra* som før. Holdebegrundelsen siger fx "MILK: lager 2 % (henter fra 25 % eller fuldt læs)". Brugerønske 7/10: mælkebilen kørte efter 2.305 l. - **1.62.67** Nyt: markørvagten tjekker hvert 30. sekund, om et køretøj i et kørende flow (i læs og aflever) har en parkerings- eller koblingsmarkør ("P …", "Connect …") som læsse- eller aflæsningsmål, og genstarter det i så fald i flowet (højst hvert 5. minut). Det fanger forkerte mål, der er gemt fra før en genindlæsning. Før kørte 'Chicken Food' mod "P Sprøjte 1" efter genindlæsning. - **1.62.66** Rettet: markmarkører genkendes også på navnet (F21 osv.), så de heller ikke lige efter indlæsning, før markskanningen har fundet dem, bruges som salgssted. I 1.62.65 fik 'Oil Mill' stadig F21. - **1.62.65** Rettet: falsk opvågning. Vågner et flow og går i dvale igen uden at have fået last på, venter det længere før næste vågn-tjek (10 → 30 → 60 min), så traktoren ikke henter vognen hvert kvarter til ingen nytte. Opvågningen logger vare, mængde og vogn ("hent STRAW ved Silo 4 (… l der, mål mangler … l)"). Før vågnede 'Sheep Food' "hent ved Silo 4", men fandt intet, da vognen var koblet på. diff --git a/FS25_ADSmartPickup/adFlowGuide.lua b/FS25_ADSmartPickup/adFlowGuide.lua index 6f9634d..bb00fd4 100644 --- a/FS25_ADSmartPickup/adFlowGuide.lua +++ b/FS25_ADSmartPickup/adFlowGuide.lua @@ -68,7 +68,7 @@ end local RUN_FIELDS = { "id", "name", "kind", "sourceBuildingIds", "targetBuildingIds", "storeBuildingIds", "products", - "ingredientMode", "ingredients", "sellAtPercent", "storeAbovePercent", "sellAbovePercent", "collectRound", "loops", + "ingredientMode", "ingredients", "sellAtPercent", "storeAbovePercent", "sellAbovePercent", "minSourcePercent", "collectRound", "loops", "returnBelowPercent", "waitPoolGroup", "vehicleIds", "wagons", "chain", } @@ -83,6 +83,7 @@ local function draftFrom(run, isNew) draft.sellAtPercent = draft.sellAtPercent or ADRuns.DEFAULT_SELL_AT_PERCENT draft.storeAbovePercent = draft.storeAbovePercent or ADRuns.DEFAULT_STORE_ABOVE_PERCENT draft.sellAbovePercent = draft.sellAbovePercent or ADRuns.DEFAULT_SELL_ABOVE_PERCENT + draft.minSourcePercent = draft.minSourcePercent or ADRuns.DEFAULT_MIN_SOURCE_PERCENT draft.returnBelowPercent = draft.returnBelowPercent or ADRuns.DEFAULT_RETURN_BELOW_PERCENT draft.loops = draft.loops or 0 draft.waitPoolGroup = draft.waitPoolGroup or "" @@ -169,7 +170,7 @@ end -- ---- valg ---- local SET_VALUES = { - kind = true, ingredientMode = true, sellAtPercent = true, storeAbovePercent = true, sellAbovePercent = true, loops = true, + kind = true, ingredientMode = true, sellAtPercent = true, storeAbovePercent = true, sellAbovePercent = true, minSourcePercent = true, loops = true, returnBelowPercent = true, waitPoolGroup = true, } local BOOL_VALUES = {showAllBuildings = true, storeAuto = true, collectRound = true} @@ -246,6 +247,12 @@ local function sellAboveOptions() return options end +local function minSourceOptions() + local options = {{label = L("spu_minSource_off"), value = 0}} + for _, option in ipairs(percentOptions(10, 90, 10)) do table.insert(options, option) end + return options +end + local function chosenSet(list) local set = {} for _, value in ipairs(list or {}) do set[value] = true end @@ -347,6 +354,7 @@ local function rowsRules(guide) end if stores then table.insert(rows, choice("storeAbovePercent", L("spu_storeAbove"), percentOptions(ADRuns.MIN_STORE_ABOVE_PERCENT, ADRuns.MAX_STORE_ABOVE_PERCENT, 5), draft.storeAbovePercent)) end if sells then table.insert(rows, choice("sellAbovePercent", L("spu_sellAbove"), sellAboveOptions(), draft.sellAbovePercent)) end + if sells then table.insert(rows, choice("minSourcePercent", L("spu_minSource"), minSourceOptions(), draft.minSourcePercent or 0)) end table.insert(rows, toggle("collectRound", L("spu_collectRound"), draft.collectRound)) return rows end @@ -504,6 +512,7 @@ local SUMMARY = { if sells then table.insert(parts, draft.sellAtPercent == 0 and L("spu_guide_flow_sumSellAlways") or L("spu_guide_flow_sumSellAt", {draft.sellAtPercent})) end if stores then table.insert(parts, L("spu_guide_flow_sumStoreAbove", {draft.storeAbovePercent})) end if sells and (draft.sellAbovePercent or 0) > 0 then table.insert(parts, L("spu_guide_flow_sumSellAbove", {draft.sellAbovePercent})) end + if sells and (draft.minSourcePercent or 0) > 0 then table.insert(parts, L("spu_guide_flow_sumMinSource", {draft.minSourcePercent})) end if draft.collectRound then table.insert(parts, L("spu_guide_flow_sumRound")) end return parts end @@ -552,6 +561,7 @@ function ADFlowGuide.result(guide) products = ADGuide.deepCopy(draft.products), ingredientMode = draft.ingredientMode, ingredients = ADGuide.deepCopy(draft.ingredients), sellAtPercent = draft.sellAtPercent, storeAbovePercent = draft.storeAbovePercent, sellAbovePercent = draft.sellAbovePercent or 0, + minSourcePercent = draft.minSourcePercent or 0, collectRound = draft.collectRound, loops = draft.loops, returnBelowPercent = draft.returnBelowPercent, waitPoolGroup = draft.waitPoolGroup or "", } diff --git a/FS25_ADSmartPickup/adOutbound.lua b/FS25_ADSmartPickup/adOutbound.lua index 21e441e..87d2e77 100644 --- a/FS25_ADSmartPickup/adOutbound.lua +++ b/FS25_ADSmartPickup/adOutbound.lua @@ -365,6 +365,7 @@ function ADOutbound.buildPlanInput(adEnv, run, vehicle) sellAtPercent = run.sellAtPercent, storeAbovePercent = run.storeAbovePercent, sellAbovePercent = run.sellAbovePercent, + minSourcePercent = run.minSourcePercent, collectRound = run.collectRound == true, products = products, } diff --git a/FS25_ADSmartPickup/adOutboundPlanner.lua b/FS25_ADSmartPickup/adOutboundPlanner.lua index 0705766..0529344 100644 --- a/FS25_ADSmartPickup/adOutboundPlanner.lua +++ b/FS25_ADSmartPickup/adOutboundPlanner.lua @@ -71,6 +71,8 @@ function ADOutboundPlanner.evaluate(product, input) priceOk = input.sellAtPercent == 0 or (percent ~= nil and percent >= (input.sellAtPercent or 90)), -- "sælg altid over X %": kilden er så fuld, at der sælges uanset pris overflow = (input.sellAbovePercent or 0) > 0 and storagePercent >= input.sellAbovePercent, + -- "hent først ved X %": salg venter til kilden er så fuld, eller et fuldt læs ligger klar (0 = fra) + minSourceOk = (input.minSourcePercent or 0) <= 0 or fullLoad or storagePercent >= input.minSourcePercent, } end @@ -101,6 +103,10 @@ local function reasonFor(product, e, input) local names = table.concat(product.reservedFor or {}, ", ") return string.format("%s: %s reserveret til %s", product.name, formatLiters(e.reserve), names ~= "" and names or "gårdens eget forbrug") end + if wantsSell(product.policy) and (e.priceOk or e.overflow) and product.quote ~= nil and not e.minSourceOk then + return string.format("%s: lager %d %% (henter fra %d %% eller fuldt læs)", product.name, + math.floor(e.storagePercent + 0.5), input.minSourcePercent) + end local canStore = wantsStore(product.policy) and product.store ~= nil if wantsSell(product.policy) and product.quote == nil and not canStore then return product.name .. ": intet nåeligt salgssted" @@ -126,7 +132,7 @@ local function collectCandidates(input) local e = ADOutboundPlanner.evaluate(product, input) local added = false if e.available >= ADOutboundPlanner.MIN_AVAILABLE_LITERS then - if wantsSell(product.policy) and (e.priceOk or e.overflow) and product.quote ~= nil and canSellWithoutReserve(e, input) then + if wantsSell(product.policy) and (e.priceOk or e.overflow) and e.minSourceOk and product.quote ~= nil and canSellWithoutReserve(e, input) then table.insert(sell, {product = product, e = e, kind = "sell", targetWayPointId = product.quote.wayPointId, targetName = product.quote.stationName, percent = e.percent}) added = true elseif wantsStore(product.policy) and (e.fullLoad or e.storageHigh or (input.feedMode and e.available >= ADOutboundPlanner.FEED_MIN_LITERS)) and product.store ~= nil then diff --git a/FS25_ADSmartPickup/adRuns.lua b/FS25_ADSmartPickup/adRuns.lua index 3ba1038..a5ba645 100644 --- a/FS25_ADSmartPickup/adRuns.lua +++ b/FS25_ADSmartPickup/adRuns.lua @@ -20,6 +20,8 @@ ADRuns.DEFAULT_STORE_ABOVE_PERCENT, ADRuns.MIN_STORE_ABOVE_PERCENT, ADRuns.MAX_S -- "Sælg altid over X %": kildens lager over grænsen sælges uanset pris (0 = fra). Så hober f.eks. gylle -- ved BGA'en sig ikke op, når prisen er lav. ADRuns.DEFAULT_SELL_ABOVE_PERCENT, ADRuns.MIN_SELL_ABOVE_PERCENT, ADRuns.MAX_SELL_ABOVE_PERCENT = 0, 0, 100 +-- "hent først ved X % i kilden" (0 = fra): salg venter til kilden er så fuld eller et fuldt læs ligger klar +ADRuns.DEFAULT_MIN_SOURCE_PERCENT, ADRuns.MIN_MIN_SOURCE_PERCENT, ADRuns.MAX_MIN_SOURCE_PERCENT = 0, 0, 95 local function copyList(list) local copy = {} @@ -86,6 +88,7 @@ local function copyRun(run) sellAtPercent = run.sellAtPercent, storeAbovePercent = run.storeAbovePercent, sellAbovePercent = run.sellAbovePercent, + minSourcePercent = run.minSourcePercent, collectRound = run.collectRound, targetWayPointId = run.targetWayPointId, targetWayPointIds = copyList(run.targetWayPointIds), @@ -138,6 +141,7 @@ function ADRuns.createRun(store, name, kind) sellAtPercent = ADRuns.DEFAULT_SELL_AT_PERCENT, storeAbovePercent = ADRuns.DEFAULT_STORE_ABOVE_PERCENT, sellAbovePercent = ADRuns.DEFAULT_SELL_ABOVE_PERCENT, + minSourcePercent = ADRuns.DEFAULT_MIN_SOURCE_PERCENT, collectRound = false, targetWayPointId = nil, targetWayPointIds = {}, @@ -207,6 +211,7 @@ function ADRuns.updateRun(store, runId, changes) if changes.sellAtPercent ~= nil then run.sellAtPercent = tonumber(changes.sellAtPercent) == 0 and 0 or clampRange(changes.sellAtPercent, ADRuns.DEFAULT_SELL_AT_PERCENT, ADRuns.MIN_SELL_AT_PERCENT, ADRuns.MAX_SELL_AT_PERCENT) end if changes.storeAbovePercent ~= nil then run.storeAbovePercent = clampRange(changes.storeAbovePercent, ADRuns.DEFAULT_STORE_ABOVE_PERCENT, ADRuns.MIN_STORE_ABOVE_PERCENT, ADRuns.MAX_STORE_ABOVE_PERCENT) end if changes.sellAbovePercent ~= nil then run.sellAbovePercent = clampRange(changes.sellAbovePercent, ADRuns.DEFAULT_SELL_ABOVE_PERCENT, ADRuns.MIN_SELL_ABOVE_PERCENT, ADRuns.MAX_SELL_ABOVE_PERCENT) end + if changes.minSourcePercent ~= nil then run.minSourcePercent = clampRange(changes.minSourcePercent, ADRuns.DEFAULT_MIN_SOURCE_PERCENT, ADRuns.MIN_MIN_SOURCE_PERCENT, ADRuns.MAX_MIN_SOURCE_PERCENT) end if changes.collectRound ~= nil then run.collectRound = changes.collectRound == true end if changes.chain ~= nil then run.chain = tostring(changes.chain) end return new @@ -442,6 +447,7 @@ function ADRuns.toRecords(store) sellAt = run.sellAtPercent, storeAbove = run.storeAbovePercent, sellAbove = run.sellAbovePercent or 0, + minSource = run.minSourcePercent or 0, collectRound = run.collectRound and 1 or 0, stopped = run.stopped and 1 or 0, sleeping = run.sleeping and 1 or 0, @@ -490,6 +496,7 @@ function ADRuns.fromRecords(records) sellAtPercent = tonumber(record.sellAt) == 0 and 0 or clampRange(record.sellAt, ADRuns.DEFAULT_SELL_AT_PERCENT, ADRuns.MIN_SELL_AT_PERCENT, ADRuns.MAX_SELL_AT_PERCENT), storeAbovePercent = clampRange(record.storeAbove, ADRuns.DEFAULT_STORE_ABOVE_PERCENT, ADRuns.MIN_STORE_ABOVE_PERCENT, ADRuns.MAX_STORE_ABOVE_PERCENT), sellAbovePercent = clampRange(record.sellAbove, ADRuns.DEFAULT_SELL_ABOVE_PERCENT, ADRuns.MIN_SELL_ABOVE_PERCENT, ADRuns.MAX_SELL_ABOVE_PERCENT), + minSourcePercent = clampRange(record.minSource, ADRuns.DEFAULT_MIN_SOURCE_PERCENT, ADRuns.MIN_MIN_SOURCE_PERCENT, ADRuns.MAX_MIN_SOURCE_PERCENT), collectRound = tonumber(record.collectRound) == 1, targetWayPointId = targets[1], targetWayPointIds = targets, diff --git a/FS25_ADSmartPickup/adRunsStorage.lua b/FS25_ADSmartPickup/adRunsStorage.lua index d94fbec..2fc8afe 100644 --- a/FS25_ADSmartPickup/adRunsStorage.lua +++ b/FS25_ADSmartPickup/adRunsStorage.lua @@ -47,6 +47,7 @@ function ADRunsStorage.writeRecords(xmlFile, records) xmlFile:setInt(key .. "#sellAt", record.sellAt or ADRuns.DEFAULT_SELL_AT_PERCENT) xmlFile:setInt(key .. "#storeAbove", record.storeAbove or ADRuns.DEFAULT_STORE_ABOVE_PERCENT) xmlFile:setInt(key .. "#sellAbove", record.sellAbove or 0) + xmlFile:setInt(key .. "#minSource", record.minSource or 0) xmlFile:setInt(key .. "#collectRound", record.collectRound or 0) -- maskinpulje: flowet stoppet + husket vogn pr. traktor xmlFile:setInt(key .. "#stopped", record.stopped or 0) @@ -81,6 +82,7 @@ function ADRunsStorage.readRecords(xmlFile) sellAt = xmlFile:getInt(key .. "#sellAt"), storeAbove = xmlFile:getInt(key .. "#storeAbove"), sellAbove = xmlFile:getInt(key .. "#sellAbove"), + minSource = xmlFile:getInt(key .. "#minSource"), collectRound = xmlFile:getInt(key .. "#collectRound"), stopped = xmlFile:getInt(key .. "#stopped"), sleeping = xmlFile:getInt(key .. "#sleeping"), diff --git a/FS25_ADSmartPickup/l10n/l10n_da.xml b/FS25_ADSmartPickup/l10n/l10n_da.xml index 4dbdef3..a25dd26 100644 --- a/FS25_ADSmartPickup/l10n/l10n_da.xml +++ b/FS25_ADSmartPickup/l10n/l10n_da.xml @@ -317,6 +317,8 @@ + + @@ -526,6 +528,7 @@ + diff --git a/FS25_ADSmartPickup/l10n/l10n_en.xml b/FS25_ADSmartPickup/l10n/l10n_en.xml index 124ebf4..c547c47 100644 --- a/FS25_ADSmartPickup/l10n/l10n_en.xml +++ b/FS25_ADSmartPickup/l10n/l10n_en.xml @@ -317,6 +317,8 @@ + + @@ -526,6 +528,7 @@ + diff --git a/FS25_ADSmartPickup/modDesc.xml b/FS25_ADSmartPickup/modDesc.xml index 5ca7ac7..8d41678 100644 --- a/FS25_ADSmartPickup/modDesc.xml +++ b/FS25_ADSmartPickup/modDesc.xml @@ -1,7 +1,7 @@ masterdraco - 1.62.67.0 + 1.62.68.0 <en>AD Smart Pickup</en> diff --git a/docs/BRUGERMANUAL.md b/docs/BRUGERMANUAL.md index fbb6768..ef66ac0 100644 --- a/docs/BRUGERMANUAL.md +++ b/docs/BRUGERMANUAL.md @@ -316,7 +316,7 @@ flow har op til 9 trin. Knapperne er **Næste**, **Tilbage** og **Annullér**. I | **Til** / **Fra** | altid | Bygningerne (se *Bygningslisten* nedenfor) | | **Varer** | altid | Forsyning: *Automatisk (det bygningen mangler)* eller *Vælg selv*. Udkørsel: pr. vare *Fra*, *Lager*, *Salg* eller *Salg, ellers lager* | | **Lager** | udkørsel med en vare på Lager | *Automatisk (nærmeste med plads)* eller *Vælg selv* blandt lagrene | -| **Regler** | altid | Forsyning: ture og *Kør hjem fra Wait under*. Udkørsel: *Sælg fra*, *Kør til lager over*, *Sælg altid når kilden er over* og *Saml op på én tur*, men kun de regler, varernes politik bruger (se [kapitel 6](#regler-for-udkørsel)) | +| **Regler** | altid | Forsyning: ture og *Kør hjem fra Wait under*. Udkørsel: *Sælg fra*, *Kør til lager over*, *Sælg altid når kilden er over*, *Hent først når kilden er over* og *Saml op på én tur*, men kun de regler, varernes politik bruger (se [kapitel 6](#regler-for-udkørsel)) | | **Vent ved** | altid | *Alle (nærmeste ledige)* eller en bestemt Wait-mappe | | **Traktorer** | altid | Se nedenfor | | **Oversigt** | altid | Resuméet. Klik på en linje for at rette den. **Start flow** eller **Gem uden at starte** | @@ -526,6 +526,7 @@ medmindre du selv vælger fabrikken under **Lager**. | **Sælg fra** | Der sælges, når prisen er mindst denne andel af varens toppris i året | 50–100 %, standard 90 % | | **Kør til lager over** | Lager-varer køres væk, når kilden er fyldt over denne andel | 50–95 %, standard 80 % | | **Sælg altid når kilden er over** | Sælger uanset pris, når den fyldeste kilde er over denne andel. Reserven røres stadig ikke | *Fra* eller 50–100 %, standard *Fra* | +| **Hent først når kilden er over** | Et salg venter, til den fyldeste kilde er mindst så fuld, eller til et fuldt læs ligger klar. Så kører mælke- og gyllebiler ikke efter få liter | *Fra (hent alt)* eller 10–90 %, standard *Fra* | | **Saml op på én tur** | Opsamlingsrunde, se nedenfor | Ja/Nej | Reglerne vises kun, når en vare bruger dem. **Sælg fra** og **Sælg altid når kilden er over** vises, når diff --git a/docs/USER_MANUAL.md b/docs/USER_MANUAL.md index 5d33d38..5f48ef9 100644 --- a/docs/USER_MANUAL.md +++ b/docs/USER_MANUAL.md @@ -319,7 +319,7 @@ press **Start flow** or **Save without starting** on the last step. | **To** / **From** | always | The buildings (see *The building list* below) | | **Goods** | always | Supply: *Automatic (what the building needs)* or *Choose myself*. Outbound: per good *Off*, *Store*, *Sell* or *Sell, else store* | | **Storage** | outbound with a good on Store | *Automatic (nearest with room)* or *Choose myself* among the storages | -| **Rules** | always | Supply: loops and *Return from Wait below*. Outbound: *Sell from*, *Drive to storage above*, *Always sell when source is above* and *Collect in one trip*, but only the rules the goods' policies use (see [chapter 6](#outbound-rules)) | +| **Rules** | always | Supply: loops and *Return from Wait below*. Outbound: *Sell from*, *Drive to storage above*, *Always sell when source is above*, *Only fetch when source is above* and *Collect in one trip*, but only the rules the goods' policies use (see [chapter 6](#outbound-rules)) | | **Wait at** | always | *All (nearest free)* or a specific Wait folder | | **Tractors** | always | See below | | **Summary** | always | The summary. Click a line to change it. **Start flow** or **Save without starting** | @@ -531,6 +531,7 @@ and tanks, unless you choose the factory yourself under **Storage**. | **Sell from** | Sell when the price is at least this share of the good's top price of the year | 50–100 %, default 90 % | | **Drive to storage above** | Store goods are hauled away when the source is filled above this share | 50–95 %, default 80 % | | **Always sell when source is above** | Sells regardless of price when the fullest source is above this share. The reserve is still not touched | *Off* or 50–100 %, default *Off* | +| **Only fetch when source is above** | A sale waits until the fullest source is at least this full, or a full load is ready, so milk and slurry trucks don't drive for a few litres | *Off (fetch any amount)* or 10–90 %, default *Off* | | **Collect in one trip** | Collection round, see below | Yes/No | The rules are only shown when a good uses them. **Sell from** and **Always sell when source is above** are