feat: justerbar tid mellem udsendelser i markflåden, standard 15 s (v1.62.41)

This commit is contained in:
2026-10-06 15:06:59 +02:00
parent 71b8d8beef
commit 6f50e3d2a1
9 changed files with 43 additions and 5 deletions
+25 -3
View File
@@ -102,9 +102,30 @@ end
-- Højst én maskine sendt ud pr. DISPATCH_GAP_MS på tværs af alle marker (in-game 27/9: 6 maskiner kørte fra
-- parkeringen i samme sekund efter Start alle).
ADFieldJobs.DISPATCH_GAP_MS = 10000
function ADFieldJobs.mayDispatch(now, lastAt)
return lastAt == nil or now - lastAt >= ADFieldJobs.DISPATCH_GAP_MS
-- Justerbart pr. savegame (brugerønske 6/10): få maskiner kan nøjes med 1–5 s, mange har brug for 30 s eller mere.
ADFieldJobs.DISPATCH_GAP_CHOICES = {1, 5, 10, 15, 20, 30, 45, 60} -- sekunder
ADFieldJobs.DISPATCH_GAP_DEFAULT_S = 15
ADFieldJobs.DISPATCH_GAP_MS = ADFieldJobs.DISPATCH_GAP_DEFAULT_S * 1000
-- Gyldigt valg (sekunder) eller standarden.
function ADFieldJobs.normalizeDispatchGap(seconds)
for _, s in ipairs(ADFieldJobs.DISPATCH_GAP_CHOICES) do
if s == seconds then return s end
end
return ADFieldJobs.DISPATCH_GAP_DEFAULT_S
end
function ADFieldJobs.dispatchGapMs()
return ADFieldJobs.normalizeDispatchGap(ADFieldJobs.state ~= nil and ADFieldJobs.state.dispatchGapS or nil) * 1000
end
function ADFieldJobs.mayDispatch(now, lastAt, gapMs)
return lastAt == nil or now - lastAt >= (gapMs or ADFieldJobs.dispatchGapMs())
end
function ADFieldJobs.setDispatchGap(seconds)
ADFieldJobs.state.dispatchGapS = ADFieldJobs.normalizeDispatchGap(seconds)
ADFieldJobs.save()
end
function ADFieldJobs.assignmentCount()
@@ -286,6 +307,7 @@ function ADFieldJobs.load()
ADFieldJobs.state.courseRecords = loaded.courseRecords or {}
ADFieldJobs.state.manual = loaded.manual or {}
ADFieldJobs.state.paused = loaded.paused == true
ADFieldJobs.state.dispatchGapS = ADFieldJobs.normalizeDispatchGap(loaded.dispatchGapS)
else
Logging.warning(ADFieldJobs.LOG_PREFIX .. "marker kunne ikke indlæses: %s", tostring(loaded))
end
+2
View File
@@ -70,6 +70,7 @@ function ADFieldStorage.save(state)
end
xmlFile:setString(ADFieldStorage.ROOT .. "#fleetMode", state.fleetMode or "all")
xmlFile:setInt(ADFieldStorage.ROOT .. "#paused", state.paused == true and 1 or 0)
xmlFile:setInt(ADFieldStorage.ROOT .. "#dispatchGap", state.dispatchGapS or 15)
-- marker er auto som standard; flaget gør engangs-omlægningen nedenfor (load) færdig
xmlFile:setInt(ADFieldStorage.ROOT .. "#autoDefault", 1)
local vehicleIndex = 0
@@ -105,6 +106,7 @@ function ADFieldStorage.load()
if xmlFile == nil then return result end
result.fleetMode = xmlFile:getString(ADFieldStorage.ROOT .. "#fleetMode") == "ticked" and "ticked" or "all"
result.paused = xmlFile:getInt(ADFieldStorage.ROOT .. "#paused") == 1
result.dispatchGapS = xmlFile:getInt(ADFieldStorage.ROOT .. "#dispatchGap")
-- engangs: en fil fra før "auto som standard" (brugerønske 5/10) får alle manuelle marker sat til auto
local migrateAuto = xmlFile:getInt(ADFieldStorage.ROOT .. "#autoDefault") ~= 1
xmlFile:iterate(ADFieldStorage.ROOT .. ".field", function(_, key)
+10 -1
View File
@@ -6,7 +6,7 @@
-- Funktionerne lægges på SmartPickupFrame (indlæses efter SmartPickupFrame.lua).
-- Markflådens rækker (vehiclePrefab/ingredientPrefab) routes til onClickFieldRow.
SmartPickupFrame.FIELD_ROW_KINDS = {fleetVehicle = true, fleetMode = true, fleetManual = true}
SmartPickupFrame.FIELD_ROW_KINDS = {fleetVehicle = true, fleetMode = true, fleetManual = true, dispatchGap = true}
SmartPickupFrame.ROLE_KEYS = {
mower = "spu_field_role_mower", tedder = "spu_field_role_tedder", rake = "spu_field_role_rake",
collector = "spu_field_role_collector", harvester = "spu_field_role_harvester", unloader = "spu_field_role_unloader",
@@ -268,6 +268,13 @@ function SmartPickupFrame:fillFleetRows(adEnv)
self:addTextRow(i18n:getText("spu_field_section_fleet"))
local useAll = ADFieldJobs.state.fleetMode ~= "ticked"
self:addToggleRow("fleetMode", i18n:getText("spu_field_fleetAll"), {i18n:getText("ui_no"), i18n:getText("ui_yes")}, useAll)
local gapTexts, gapState = {}, 1
local gap = ADFieldJobs.normalizeDispatchGap(ADFieldJobs.state.dispatchGapS)
for index, seconds in ipairs(ADFieldJobs.DISPATCH_GAP_CHOICES) do
table.insert(gapTexts, string.format("%d s", seconds))
if seconds == gap then gapState = index end
end
self:addFieldSiloChoiceRow("dispatchGap", i18n:getText("spu_field_dispatchGap"), gapTexts, gapState)
local rigs = {}
for _, rig in ipairs(ADFieldJobs.getRigs(adEnv)) do table.insert(rigs, rig) end
table.sort(rigs, function(a, b)
@@ -359,6 +366,8 @@ function SmartPickupFrame:onClickFieldRow(state, data)
ADFieldJobs.toggleFleet(data.vehicleId)
elseif data.kind == "fleetMode" then
ADFieldJobs.setFleetMode(isOn and "all" or "ticked")
elseif data.kind == "dispatchGap" then
ADFieldJobs.setDispatchGap(ADFieldJobs.DISPATCH_GAP_CHOICES[state])
elseif data.kind == "fleetManual" then
local wantManual = not isOn -- Ja = kører selv på vejen
if ((ADFieldJobs.state.manual or {})[data.vehicleId] == true) ~= wantManual then ADFieldJobs.toggleManual(data.vehicleId) end
+1
View File
@@ -231,6 +231,7 @@
<text name="spu_field_target_keep" text="%s står allerede: slås og samles op, hver gang den er klar"/>
<text name="spu_field_target_switch" text="%s får lov at vokse færdig og høstes/slås; derefter klargøres og tilsås med %s"/>
<text name="spu_field_waitSowing" text="venter på såtid for %s"/>
<text name="spu_field_dispatchGap" text="Tid mellem hver maskine der sendes ud"/>
<text name="spu_field_fleetAll" text="Brug alle ledige maskiner (Nej = kun med flueben)"/>
<text name="spu_field_role_baler" text="ballepresser"/>
<text name="spu_field_role_baleCollector" text="ballesamler"/>
+1
View File
@@ -231,6 +231,7 @@
<text name="spu_field_target_keep" text="%s is already there: mowed and collected every time it is ready"/>
<text name="spu_field_target_switch" text="%s is left to finish growing and is harvested/mowed; then the field is prepared and sown with %s"/>
<text name="spu_field_waitSowing" text="waiting for sowing time for %s"/>
<text name="spu_field_dispatchGap" text="Time between each machine sent out"/>
<text name="spu_field_fleetAll" text="Use all free machines (No = only ticked ones)"/>
<text name="spu_field_role_baler" text="baler"/>
<text name="spu_field_role_baleCollector" text="bale collector"/>
+1 -1
View File
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<modDesc descVersion="107">
<author>masterdraco</author>
<version>1.62.40.0</version>
<version>1.62.41.0</version>
<title>
<en>AD Smart Pickup</en>
</title>