feat(lager): lagerture kan aflæsse i gårdens egne fabrikker der bruger varen som input (gylle -> biogasanlæg) (v1.17.6.0)
This commit is contained in:
@@ -42,6 +42,33 @@ local function isSilo(station, homeStation)
|
||||
and placeable.spec_productionPoint == nil and (homeStation == nil or placeable ~= homeStation.owningPlaceable)
|
||||
end
|
||||
|
||||
local function usesAsInput(placeable, fillType)
|
||||
local productionPoint = placeable.spec_productionPoint ~= nil and placeable.spec_productionPoint.productionPoint or nil
|
||||
for _, production in ipairs(productionPoint ~= nil and productionPoint.productions or {}) do
|
||||
for _, input in ipairs(production.inputs or {}) do
|
||||
if input.type == fillType then return true end
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
-- Lagermål: rene siloer; med allowFactories også gårdens EGNE fabrikker der bruger varen som input
|
||||
-- (fx et biogasanlæg med gyllesilo). Stalde, fremmede anlæg og hjemmet (målet selv) aldrig.
|
||||
function ADLoadSwap.isStoreTarget(station, fillType, homeStation, allowFactories)
|
||||
if isSilo(station, homeStation) then
|
||||
return true
|
||||
end
|
||||
local placeable = station.owningPlaceable
|
||||
if not allowFactories or placeable == nil or placeable.spec_productionPoint == nil or placeable.getHusbandryFillLevel ~= nil then
|
||||
return false
|
||||
end
|
||||
if homeStation ~= nil and placeable == homeStation.owningPlaceable then
|
||||
return false
|
||||
end
|
||||
local owned = ADPrices ~= nil and ADPrices.isOwnedByPlayer ~= nil and ADPrices.isOwnedByPlayer(placeable)
|
||||
return owned and usesAsInput(placeable, fillType)
|
||||
end
|
||||
|
||||
local function acceptsRest(station, fillType, rest, farmId)
|
||||
if station.getIsFillTypeSupported ~= nil and not station:getIsFillTypeSupported(fillType) then
|
||||
return false
|
||||
@@ -70,7 +97,7 @@ function ADLoadSwap.rankDumpCandidates(candidates, avoidMarkers)
|
||||
return ranked
|
||||
end
|
||||
|
||||
function ADLoadSwap.findDumpMarker(adEnv, vehicle, fillType, rest, homeWayPointId, isReachable, excludedPlaceables, avoidMarkers)
|
||||
function ADLoadSwap.findDumpMarker(adEnv, vehicle, fillType, rest, homeWayPointId, isReachable, excludedPlaceables, avoidMarkers, allowFactories)
|
||||
if vehicle.rootNode == nil then
|
||||
return nil, "køretøjet har ingen position"
|
||||
end
|
||||
@@ -82,7 +109,7 @@ function ADLoadSwap.findDumpMarker(adEnv, vehicle, fillType, rest, homeWayPointI
|
||||
for _, marker in pairs(adEnv.ADGraphManager:getMapMarkers()) do
|
||||
local station = ADSmartPickup.getUnloadStationAtWayPointId(adEnv, marker.id, farmId)
|
||||
local isExcluded = excludedPlaceables ~= nil and excludedPlaceables[station ~= nil and station.owningPlaceable or false] == true
|
||||
if station ~= nil and isSilo(station, homeStation) and not isExcluded then
|
||||
if station ~= nil and ADLoadSwap.isStoreTarget(station, fillType, homeStation, allowFactories) and not isExcluded then
|
||||
silos = silos + 1
|
||||
if acceptsRest(station, fillType, rest, farmId) then
|
||||
withSpace = withSpace + 1
|
||||
@@ -105,7 +132,7 @@ function ADLoadSwap.findDumpMarker(adEnv, vehicle, fillType, rest, homeWayPointI
|
||||
end
|
||||
end
|
||||
if silos == 0 then
|
||||
return nil, "ingen silo med aflæsningsmarkør fundet (siloen skal have en AD-markør ved aflæsningstriggeren)"
|
||||
return nil, allowFactories and "ingen silo eller egen fabrik der bruger varen, med aflæsningsmarkør (sæt en AD-markør ved aflæsningstriggeren)" or "ingen silo med aflæsningsmarkør fundet (siloen skal have en AD-markør ved aflæsningstriggeren)"
|
||||
elseif withSpace == 0 then
|
||||
return nil, string.format("%d silo(er) fundet, men ingen tager varen med plads til %.0f l", silos, rest)
|
||||
end
|
||||
|
||||
@@ -201,7 +201,7 @@ local function findStoreMarker(adEnv, vehicle, product, capacity, sources, liter
|
||||
end
|
||||
local liters = math.max(1, math.min(available, capacity or available))
|
||||
local avoid = ADRunsController ~= nil and ADRunsController.getPickupMarkers ~= nil and ADRunsController.getPickupMarkers() or nil
|
||||
local marker = ADLoadSwap.findDumpMarker(adEnv, vehicle, product.fillType, liters, nil, isReachable, ADSources.getSourcePlaceables(sources), avoid)
|
||||
local marker = ADLoadSwap.findDumpMarker(adEnv, vehicle, product.fillType, liters, nil, isReachable, ADSources.getSourcePlaceables(sources), avoid, true)
|
||||
if marker == nil then
|
||||
return nil
|
||||
end
|
||||
@@ -479,8 +479,8 @@ function ADOutbound.choosePickup(adEnv, vehicle)
|
||||
local runStatus = getStatus(run)
|
||||
runStatus.reasons = reasons
|
||||
for _, reason in ipairs(reasons) do
|
||||
if string.find(reason, ": ingen silo med plads", 1, true) then
|
||||
warnOnce(adEnv, vehicle, "store:" .. reason, string.format("'%s' finder ingen silo med plads (%s)", tostring(ADRuns.vehicleLabel(vehicle)), reason))
|
||||
if string.find(reason, ": intet lager med plads", 1, true) then
|
||||
warnOnce(adEnv, vehicle, "store:" .. reason, string.format("'%s' finder intet lager med plads (%s)", tostring(ADRuns.vehicleLabel(vehicle)), reason))
|
||||
end
|
||||
end
|
||||
if trip == nil then
|
||||
|
||||
@@ -99,7 +99,7 @@ local function reasonFor(product, e, input)
|
||||
return product.name .. ": intet nåeligt salgssted"
|
||||
end
|
||||
if wantsStore(product.policy) and product.store == nil and (e.fullLoad or e.storageHigh) and not e.priceOk then
|
||||
return product.name .. ": ingen silo med plads"
|
||||
return product.name .. ": intet lager med plads (silo eller egen fabrik der bruger varen)"
|
||||
end
|
||||
local parts = {}
|
||||
if wantsSell(product.policy) and e.percent ~= nil then
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||
<modDesc descVersion="107">
|
||||
<author>masterdraco</author>
|
||||
<version>1.17.5.0</version>
|
||||
<version>1.17.6.0</version>
|
||||
<title>
|
||||
<en>AD Smart Pickup</en>
|
||||
</title>
|
||||
|
||||
Reference in New Issue
Block a user