feat: stenplukning efter jordbehandling (1.62.207)
This commit is contained in:
@@ -114,6 +114,7 @@ function ADFields.soilNeeds(levels, settings)
|
||||
return {
|
||||
lime = settings.limeRequired and levels.lime ~= nil and levels.lime < 1 or false,
|
||||
plow = settings.plowingRequired and levels.plowLevel ~= nil and levels.plowLevel < 1 or false,
|
||||
stones = settings.stones == true,
|
||||
}
|
||||
end
|
||||
|
||||
@@ -180,6 +181,33 @@ local function readWeed(x, z)
|
||||
return value
|
||||
end
|
||||
|
||||
function ADFields.mapHasStones()
|
||||
local system = g_currentMission ~= nil and g_currentMission.stoneSystem or nil
|
||||
if system == nil or system.getMapHasStones == nil then return false end
|
||||
local ok, has = pcall(system.getMapHasStones, system)
|
||||
return ok and has == true
|
||||
end
|
||||
|
||||
-- Diagnose til kalibrering (in-game): pixels pr. stenværdi på hele marken, fx "0:1200 1:40 2:0 3:8800 (min 1, max 3)".
|
||||
-- Spillets dokumentation siger ikke, hvilke værdier der er "sten der ligger" og "samlet op" (StonePickMission tæller
|
||||
-- NOTEQUAL max blandt > 0). Indtil det er målt, køres stenplukning altid efter jordbehandlingen.
|
||||
function ADFields.stoneHistogram(field)
|
||||
local system = g_currentMission ~= nil and g_currentMission.stoneSystem or nil
|
||||
if system == nil or field == nil or field.getDensityMapPolygon == nil then return nil end
|
||||
local mapId, firstChannel, numChannels = system:getDensityMapData()
|
||||
local minValue, maxValue = system:getMinMaxValues()
|
||||
local parts = {}
|
||||
for value = 0, maxValue do
|
||||
local modifier = DensityMapModifier.new(mapId, firstChannel, numChannels, g_terrainNode or g_currentMission.terrainRootNode)
|
||||
local filter = DensityMapFilter.new(modifier)
|
||||
filter:setValueCompareParams(DensityValueCompareType.EQUAL, value)
|
||||
field:getDensityMapPolygon():applyToModifier(modifier)
|
||||
local _, area = modifier:executeGet(filter)
|
||||
table.insert(parts, string.format("%d:%d", value, math.floor(area or 0)))
|
||||
end
|
||||
return string.format("%s (min %s, max %s)", table.concat(parts, " "), tostring(minValue), tostring(maxValue))
|
||||
end
|
||||
|
||||
local function missionSettings()
|
||||
local info = g_currentMission ~= nil and g_currentMission.missionInfo or {}
|
||||
local function flag(value) return value == nil or value == true end
|
||||
@@ -187,6 +215,8 @@ local function missionSettings()
|
||||
limeRequired = flag(info.limeRequired),
|
||||
plowingRequired = flag(info.plowingRequiredEnabled),
|
||||
weedsEnabled = flag(info.weedsEnabled),
|
||||
-- sten: kortet skal have sten, og de skal være slået til i savegamet
|
||||
stones = ADFields.mapHasStones() and flag(info.stonesEnabled),
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user