feat: påfyldning fra paller (løse og i palleskur); risplanterens stiklinger genkendes (v1.62.16)
This commit is contained in:
@@ -238,15 +238,31 @@ local function seederOf(vehicle)
|
||||
return nil
|
||||
end
|
||||
|
||||
-- Har såmaskinen frø på? (fyldenheder med SEEDS)
|
||||
-- Såmaskinens frø-vare: SEEDS når enheden tager det, ellers enhedens egen (risplanter: RICESAPLINGS — in-game 4/10).
|
||||
function ADCpBridge.seedFillTypeOf(seeder)
|
||||
if seeder == nil or g_fillTypeManager == nil then return nil end
|
||||
local seedsIndex = g_fillTypeManager:getFillTypeIndexByName("SEEDS")
|
||||
local spec = seeder.spec_sowingMachine
|
||||
local unitIndex = spec ~= nil and spec.fillUnitIndex or nil
|
||||
local units = seeder.spec_fillUnit ~= nil and seeder.spec_fillUnit.fillUnits or {}
|
||||
local unit = unitIndex ~= nil and units[unitIndex] or nil
|
||||
if unit == nil or unit.supportedFillTypes == nil then return seedsIndex end
|
||||
if unit.supportedFillTypes[seedsIndex] then return seedsIndex end
|
||||
for fillType, supported in pairs(unit.supportedFillTypes) do
|
||||
if supported then return fillType end
|
||||
end
|
||||
return seedsIndex
|
||||
end
|
||||
|
||||
-- Har såmaskinen frø på? (frø-enheden, uanset om det er SEEDS eller fx ris-stiklinger)
|
||||
function ADCpBridge.hasSeeds(vehicle)
|
||||
local seeder = seederOf(vehicle)
|
||||
if seeder == nil then return false end
|
||||
local ok, has = pcall(function()
|
||||
local seedsIndex = g_fillTypeManager:getFillTypeIndexByName("SEEDS")
|
||||
local seedType = ADCpBridge.seedFillTypeOf(seeder)
|
||||
for index, unit in ipairs(seeder.spec_fillUnit ~= nil and seeder.spec_fillUnit.fillUnits or {}) do
|
||||
if unit.fillType == seedsIndex and (unit.fillLevel or 0) > 0 then return true end
|
||||
if unit.supportedFillTypes ~= nil and unit.supportedFillTypes[seedsIndex] and seeder:getFillUnitFillLevel(index) > 0 then return true end
|
||||
if unit.fillType == seedType and (unit.fillLevel or 0) > 0 then return true end
|
||||
if unit.supportedFillTypes ~= nil and unit.supportedFillTypes[seedType] and seeder:getFillUnitFillLevel(index) > 0 then return true end
|
||||
end
|
||||
return false
|
||||
end)
|
||||
@@ -289,7 +305,7 @@ end
|
||||
function ADCpBridge.getRefillFillType(vehicle, role)
|
||||
for _, object in ipairs(collect(vehicle)) do
|
||||
if object.spec_sowingMachine ~= nil and g_fillTypeManager ~= nil then
|
||||
return g_fillTypeManager:getFillTypeIndexByName("SEEDS")
|
||||
return ADCpBridge.seedFillTypeOf(object)
|
||||
end
|
||||
end
|
||||
for _, object in ipairs(collect(vehicle)) do
|
||||
|
||||
Reference in New Issue
Block a user