feat(markarbejde): bygget-over marker (groundType NONE / ingen markjord — stald, biogas, gårdsplads) er ikke med i oversigten eller arbejdet (v1.29.0.0)
This commit is contained in:
@@ -159,7 +159,17 @@ function ADFields.readFieldState(field)
|
||||
local state = field ~= nil and field.fieldState or nil
|
||||
if type(state) ~= "table" or type(state.fruitTypeIndex) ~= "number" then return nil end
|
||||
local fruitIndex = state.fruitTypeIndex > 0 and state.fruitTypeIndex or nil
|
||||
return {fruitIndex = fruitIndex, growthState = fruitIndex ~= nil and state.growthState or nil}
|
||||
local groundNone = type(FieldGroundType) == "table" and FieldGroundType.NONE or 0
|
||||
return {fruitIndex = fruitIndex, growthState = fruitIndex ~= nil and state.growthState or nil,
|
||||
noFieldGround = type(state.groundType) == "number" and state.groundType == groundNone}
|
||||
end
|
||||
|
||||
-- Kan marken dyrkes? Nej hvis spillet siger "ingen markjord" (groundType NONE: bygget over — gårdsplads,
|
||||
-- stald, biogasanlæg), eller hvis intet prøvepunkt ligger på markjord. En markensilo i et hjørne ændrer
|
||||
-- intet: resten af marken er stadig markjord.
|
||||
function ADFields.isCultivable(state, onFieldPoints)
|
||||
if state ~= nil and state.noFieldGround then return false end
|
||||
return (onFieldPoints or 0) > 0
|
||||
end
|
||||
|
||||
-- Markens omrids som {{x, z}, ...}. FS25: field:getDensityMapPolygon():getVerticesList() (flad liste
|
||||
@@ -302,6 +312,7 @@ function ADFields.scanPerFruit(scan)
|
||||
-- (getFieldDataAtWorldPosition giver isOnField, densityBits, groundType — IKKE vækststadie)
|
||||
local state = ADFields.readFieldState(info.field)
|
||||
info.growthState = state ~= nil and state.growthState or nil
|
||||
info.cultivable = ADFields.isCultivable(state, #scan.points)
|
||||
if state ~= nil then
|
||||
info.fruitIndex = state.fruitIndex
|
||||
else
|
||||
@@ -486,7 +497,8 @@ function ADFields.list()
|
||||
local infos = {}
|
||||
for _, entry in ipairs(ADFields.order) do
|
||||
local info = ADFields.cache[entry.id]
|
||||
if info ~= nil then table.insert(infos, info) end
|
||||
-- bygget-over marker (stald, biogas, gårdsplads) kan ikke dyrkes: ikke med i oversigt/arbejde
|
||||
if info ~= nil and info.cultivable ~= false then table.insert(infos, info) end
|
||||
end
|
||||
ADFields.listCache = infos
|
||||
return infos
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||
<modDesc descVersion="107">
|
||||
<author>masterdraco</author>
|
||||
<version>1.28.9.0</version>
|
||||
<version>1.29.0.0</version>
|
||||
<title>
|
||||
<en>AD Smart Pickup</en>
|
||||
</title>
|
||||
|
||||
@@ -82,5 +82,17 @@ field.fieldState = {fruitTypeIndex = 0, growthState = 0}
|
||||
cropAt = function() return nil end
|
||||
info = rescan()
|
||||
check("PG9 ingen afgrøde = bar uden stub", info and info.kind .. "/" .. tostring(info.stubbleOf), "bare/nil")
|
||||
-- PG10-12: bygget-over mark (fields.xml: groundType NONE — gårdsplads/stald/biogas) er ikke med i listen
|
||||
field.fieldState = {fruitTypeIndex = 0, growthState = 0, groundType = 0}
|
||||
info = rescan()
|
||||
check("PG10 ingen markjord = kan ikke dyrkes", info and info.cultivable, false)
|
||||
check("PG10 ikke i marklisten", #ADFields.list(), 0)
|
||||
field.fieldState = {fruitTypeIndex = MAIZE, growthState = 2, groundType = 7}
|
||||
cropAt = function(x) return MAIZE end
|
||||
info = rescan()
|
||||
check("PG11 markjord = kan dyrkes", info and info.cultivable, true)
|
||||
check("PG11 i marklisten", #ADFields.list(), 1)
|
||||
check("PG12 ingen punkter på markjord", ADFields.isCultivable(nil, 0), false)
|
||||
|
||||
print(failures == 0 and "\nALLE TESTS OK" or ("\n" .. failures .. " FEJL"))
|
||||
os.exit(failures == 0 and 0 or 1)
|
||||
|
||||
Reference in New Issue
Block a user