feat(bomuld): balleopsamling slutter først når modulerne er samlet op (v1.62.270)
This commit is contained in:
@@ -629,6 +629,41 @@ function ADFieldWork.seedsRefillable(adEnv, vehicle, x, z)
|
||||
return ok and result == true
|
||||
end
|
||||
|
||||
-- Ren: hvor mange af ballerne ligger løst (ikke på en vogn) inden for markens polygon med varen?
|
||||
-- bales = {{x, z, fillType, mounted}}
|
||||
function ADFieldWork.countBalesIn(bales, verts, fillType)
|
||||
local count = 0
|
||||
if #(verts or {}) < 3 then return 0 end
|
||||
for _, bale in ipairs(bales or {}) do
|
||||
if not bale.mounted and bale.fillType == fillType and ADFieldJobs.insidePolygon(bale.x, bale.z, verts) then
|
||||
count = count + 1
|
||||
end
|
||||
end
|
||||
return count
|
||||
end
|
||||
|
||||
-- Baller med afgrødens vare på marken (spillets balleliste, som Courseplays ballefinder). nil = kan ikke tælles.
|
||||
function ADFieldWork.countFieldBales(info, fruit)
|
||||
if info == nil or #(info.verts or {}) < 3 or g_currentMission == nil or g_currentMission.slotSystem == nil
|
||||
or SlotSystem == nil or g_fillTypeManager == nil then return nil end
|
||||
local fillType = g_fillTypeManager:getFillTypeIndexByName(string.upper(tostring(fruit)))
|
||||
local limits = g_currentMission.slotSystem.objectLimits
|
||||
local list = limits ~= nil and limits[SlotSystem.LIMITED_OBJECT_BALE] ~= nil and limits[SlotSystem.LIMITED_OBJECT_BALE].objects or nil
|
||||
if fillType == nil or list == nil then return nil end
|
||||
local bales = {}
|
||||
for _, object in pairs(list) do
|
||||
-- varen først (billigt), så positionen; på en vogn/stropper/autoload = ikke løs (som Courseplays isLoaded)
|
||||
if object.getFillType ~= nil and object:getFillType() == fillType and object.nodeId ~= nil and object.nodeId ~= 0
|
||||
and entityExists(object.nodeId) then
|
||||
local x, _, z = getWorldTranslation(object.nodeId)
|
||||
table.insert(bales, {x = x, z = z, fillType = fillType,
|
||||
mounted = object.mountObject ~= nil or object.dynamicMountObject ~= nil or object.tensionMountObject ~= nil
|
||||
or object.currentlyLoadedOnAPalletAutoLoaderId ~= nil})
|
||||
end
|
||||
end
|
||||
return ADFieldWork.countBalesIn(bales, info.verts, fillType)
|
||||
end
|
||||
|
||||
-- Ballelasterens fyldtyper for en ballehøst-afgrøde: {SQUAREBALE_COTTON, ROUNDBALE_COTTON} som indeks (de findes).
|
||||
function ADFieldWork.baleFillTypes(fruit)
|
||||
local result = {}
|
||||
|
||||
Reference in New Issue
Block a user