diff --git a/FS25_ADSmartPickup/adFields.lua b/FS25_ADSmartPickup/adFields.lua index 5291aa7..da84168 100644 --- a/FS25_ADSmartPickup/adFields.lua +++ b/FS25_ADSmartPickup/adFields.lua @@ -318,7 +318,7 @@ end local function newScan(adEnv, entry) local field, fieldId = entry.field, entry.id local scan = {id = fieldId, queue = {}, head = 1, tail = 0, points = {}, fruitVotes = {}, - anySum = 0, readySum = 0, immatureSum = 0, soil = {fert = {0, 0}, lime = {0, 0}, plowLevel = {0, 0}, weed = {0, 0}}} + anySum = 0, readySum = 0, immatureSum = 0, totalSum = 0, soil = {fert = {0, 0}, lime = {0, 0}, plowLevel = {0, 0}, weed = {0, 0}}} local info = {id = fieldId, field = field, points = scan.points, verts = {}, mowable = false, readyRatio = 0} scan.info = info -- 1) polygon og kandidatpunkter (centroid + halvvejs mod op til 8 hjørner) @@ -387,7 +387,9 @@ function ADFields.scanPerFruit(scan) push(scan, function() local x, z = point.x, point.z if fruitIndex ~= nil then - local okA, _, anyPixels, _, pointState = pcall(FSDensityMapUtil.getFruitArea, fruitIndex, x - 2, z - 2, x + 2, z, x, z + 2, true, true) + -- returnerer fruitValue, numPixels (afgrøde i høsthøjde), totalNumPixels (hele arealet), growthState + local okA, _, anyPixels, totalPixels, pointState = pcall(FSDensityMapUtil.getFruitArea, fruitIndex, x - 2, z - 2, x + 2, z, x, z + 2, true, true) + if okA and type(totalPixels) == "number" then scan.totalSum = scan.totalSum + totalPixels end if okA and anyPixels then scan.anySum = scan.anySum + anyPixels if not ADFields.isPrime(pointState, prime) then scan.immatureSum = scan.immatureSum + anyPixels end @@ -433,6 +435,8 @@ local function finishScan(adEnv, scan) info.readyRatio = scan.anySum > 0 and scan.readySum / scan.anySum or 0 info.immatureRatio = scan.anySum > 0 and scan.immatureSum / scan.anySum or 0 info.anyPixels = scan.anySum + -- andel af hele arealet der stadig står i høsthøjde (fremdrift på fanen Måned) + info.standingRatio = scan.totalSum > 0 and scan.readySum / scan.totalSum or nil fruit = g_fruitTypeManager:getFruitTypeByIndex(info.fruitIndex) info.fruitName = fruit ~= nil and fruit.name or nil info.harvestFillType = fruit ~= nil and fruit.fillType ~= nil and fruit.fillType.index or nil diff --git a/FS25_ADSmartPickup/adMonthView.lua b/FS25_ADSmartPickup/adMonthView.lua index 21ac50c..1d77445 100644 --- a/FS25_ADSmartPickup/adMonthView.lua +++ b/FS25_ADSmartPickup/adMonthView.lua @@ -82,11 +82,16 @@ function ADMonthView.window(field, info, ctx) return "ok" end --- Fremdrift 0-1: Courseplays egen (gennemsnit af sættene) vinder; høst/slåning ellers ud fra hvor meget --- af afgrøden der er væk; ellers ukendt (nil). +-- Fremdrift 0-1. Høst/slåning: andelen af HELE arealet der stadig står (standingRatio) — readyRatio duer ikke, +-- for slået/høstet afgrøde forsvinder også fra dens nævner (in-game 27/9 F90: halvt slået = 0 %), og +-- Courseplays tal er kun positionen i kurset (starter forfra på 0 ved genstart). Øvrige trin: Courseplay. function ADMonthView.progress(field, info, cpProgress) + local cropStage = field.stage == "harvesting" or field.stage == "mowing" + if cropStage and type(info.standingRatio) == "number" then + return math.max(0, math.min(1, 1 - info.standingRatio)) + end if type(cpProgress) == "number" then return math.max(0, math.min(1, cpProgress)) end - if (field.stage == "harvesting" or field.stage == "mowing") and type(info.readyRatio) == "number" then + if cropStage and type(info.readyRatio) == "number" then return math.max(0, math.min(1, 1 - info.readyRatio)) end return nil diff --git a/FS25_ADSmartPickup/modDesc.xml b/FS25_ADSmartPickup/modDesc.xml index 37ceb6a..5366744 100644 --- a/FS25_ADSmartPickup/modDesc.xml +++ b/FS25_ADSmartPickup/modDesc.xml @@ -1,7 +1,7 @@ masterdraco - 1.35.0.0 + 1.35.1.0 <en>AD Smart Pickup</en> diff --git a/tests/test_adMonthView.lua b/tests/test_adMonthView.lua index e28249a..c8425a9 100644 --- a/tests/test_adMonthView.lua +++ b/tests/test_adMonthView.lua @@ -28,7 +28,11 @@ check("MV3 ukendte data", V.withersIn({witheredState = 7}, 7, 6), false) -- MV4: fremdrift local harvest = M.with(M.newField(15), {stage = "harvesting", kind = "harvest"}) -check("MV4 CP vinder", V.progress(harvest, {readyRatio = 0.9}, 0.5), 0.5) +check("MV4 CP vinder uden arealtal", V.progress(harvest, {readyRatio = 0.9}, 0.5), 0.5) +-- in-game 27/9 F90: halvt slået græs viste 0 % — slået græs tæller ikke i readyRatio's nævner +check("MV4 slåning ud fra hele arealet", V.progress(M.with(harvest, {stage = "mowing"}), {readyRatio = 1, standingRatio = 0.5}, nil), 0.5) +check("MV4 areal slår CP (kursus genstartet = 0)", V.progress(harvest, {readyRatio = 1, standingRatio = 0.4}, 0), 0.6) +check("MV4 pleje bruger stadig CP", V.progress(M.with(harvest, {stage = "fertilizing"}), {standingRatio = 0.4}, 0.3), 0.3) check("MV4 høst ud fra afgrøde", V.progress(harvest, {readyRatio = 0.25}, nil), 0.75) check("MV4 kultivering ukendt", V.progress(M.with(harvest, {stage = "cultivating"}), {readyRatio = 0}, nil), nil) check("MV4 tekst", V.percentText(0.504), "50 %")