feat: stalde som kilde til udkørsel (mælketank/gylle via staldens læssestation) (v1.12.19.0)
This commit is contained in:
@@ -63,7 +63,7 @@ end
|
||||
-- Palle eller bulk ved DENNE kilde: silo = bulk; objektlager = palle; fabrik = bulk hvis
|
||||
-- markørens læssestation udleverer varen, ellers palle hvis varen er en palletype.
|
||||
function ADSources.isPalletAt(source, fillType)
|
||||
if source.kind == "silo" then
|
||||
if source.kind == "silo" or source.kind == "husbandry" then
|
||||
return false
|
||||
elseif source.kind == "objectStorage" then
|
||||
return true
|
||||
@@ -137,6 +137,10 @@ function ADSources.identify(adEnv, wayPointId, farmId)
|
||||
if placeable ~= nil and placeable.spec_silo ~= nil then
|
||||
return {kind = "silo", placeable = placeable, station = station, wayPointId = wayPointId, name = getPlaceableName(placeable, markerName)}
|
||||
end
|
||||
-- stald: mælketank, gyllebeholder m.m. (læssestation på en husbandry-placeable)
|
||||
if placeable ~= nil and placeable.getHusbandryFillLevel ~= nil then
|
||||
return {kind = "husbandry", placeable = placeable, station = station, wayPointId = wayPointId, name = getPlaceableName(placeable, markerName)}
|
||||
end
|
||||
-- Rene pallefabrikker (halmvarer, bageri ...) har ingen læssestation: find dem på afstand
|
||||
-- til pallespawneren; dernæst objektlagre.
|
||||
local factory = findPlaceableNear(wayPoint, farmId, isProductionPoint)
|
||||
@@ -274,12 +278,43 @@ local function getObjectStorageProducts(source)
|
||||
return products
|
||||
end
|
||||
|
||||
-- Stald: det læssestationen udleverer (mælk, gylle ...) med staldens eget niveau/kapacitet.
|
||||
local function getHusbandryProducts(source)
|
||||
local placeable, station = source.placeable, source.station
|
||||
local fillTypes = {}
|
||||
for fillType, supported in pairs(station ~= nil and station.supportedFillTypes or {}) do
|
||||
if supported == true then table.insert(fillTypes, fillType) end
|
||||
end
|
||||
if #fillTypes == 0 and station ~= nil and station.getIsFillTypeSupported ~= nil and g_fillTypeManager ~= nil then
|
||||
for _, name in ipairs({"MILK", "GOATMILK", "BUFFALOMILK", "SHEEPMILK", "LIQUIDMANURE", "MANURE", "DIGESTATE"}) do
|
||||
local fillType = g_fillTypeManager.getFillTypeIndexByName ~= nil and g_fillTypeManager:getFillTypeIndexByName(name) or nil
|
||||
if fillType ~= nil then
|
||||
local ok, value = pcall(station.getIsFillTypeSupported, station, fillType)
|
||||
if ok and value == true then table.insert(fillTypes, fillType) end
|
||||
end
|
||||
end
|
||||
end
|
||||
table.sort(fillTypes)
|
||||
local products = {}
|
||||
for _, fillType in ipairs(fillTypes) do
|
||||
local level = placeable:getHusbandryFillLevel(fillType) or 0
|
||||
local capacity = placeable.getHusbandryCapacity ~= nil and (placeable:getHusbandryCapacity(fillType) or 0) or 0
|
||||
if capacity <= 0 and placeable.getHusbandryFreeCapacity ~= nil then
|
||||
capacity = level + (placeable:getHusbandryFreeCapacity(fillType) or 0)
|
||||
end
|
||||
table.insert(products, newProduct(fillType, level, level, capacity, false))
|
||||
end
|
||||
return products
|
||||
end
|
||||
|
||||
-- Varer ved kilden med tilgængelig mængde: { {fillType, name, title, available, level, capacity, isPallet} }.
|
||||
function ADSources.getProducts(adEnv, source, farmId)
|
||||
if source.kind == "factory" then
|
||||
return getFactoryProducts(source, farmId)
|
||||
elseif source.kind == "silo" then
|
||||
return getSiloProducts(source)
|
||||
elseif source.kind == "husbandry" then
|
||||
return getHusbandryProducts(source)
|
||||
elseif source.kind == "objectStorage" then
|
||||
return getObjectStorageProducts(source)
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||
<modDesc descVersion="107">
|
||||
<author>masterdraco</author>
|
||||
<version>1.12.18.0</version>
|
||||
<version>1.12.19.0</version>
|
||||
<title>
|
||||
<en>AD Smart Pickup</en>
|
||||
</title>
|
||||
|
||||
Reference in New Issue
Block a user