feat: marker har Til/Fra og er Fra som standard; Stop slår marken fra (1.62.200)
This commit is contained in:
@@ -466,6 +466,8 @@ local function readFields(data)
|
||||
if field.stage == "harvesting" and info.fruitName ~= nil then data.harvesting[info.fruitName] = true end
|
||||
return {id = info.id, areaHa = ADFields.polygonAreaHa(info.verts), fruit = fruit,
|
||||
targetFruit = plan.targetFruit, targetSource = plan.targetSource, chainFree = plan.chainFree == true, product = plan.product,
|
||||
-- slået fra i marklisten: kæden skifter ikke selv afgrøde (forslag kan stadig godkendes)
|
||||
enabled = plan.mode == "auto",
|
||||
permanent = ADChainData.isPermanent(info.fruitName or field.lastFruit), excluded = info.kind == "mowable"}
|
||||
end)
|
||||
if ok then
|
||||
|
||||
@@ -55,8 +55,8 @@ function ADChainRun.switchFields(data, actions)
|
||||
for _, action in ipairs(actions or {}) do
|
||||
if switched >= ADChain.MAX_FIELD_SWITCHES then break end
|
||||
local field = fieldById(data.fields, action.fieldId)
|
||||
-- brugerens egen målafgrøde røres aldrig (dobbelttjek oven i ADCropPlan)
|
||||
if action.mode == "auto" and field ~= nil and field.targetSource ~= "user" then
|
||||
-- brugerens egen målafgrøde røres aldrig (dobbelttjek oven i ADCropPlan); en mark slået fra heller ikke
|
||||
if action.mode == "auto" and field ~= nil and field.targetSource ~= "user" and field.enabled ~= false then
|
||||
local ok, err = pcall(ADFieldJobs.setTarget, action.fieldId, action.to, "chain", action.product)
|
||||
if ok then
|
||||
switched = switched + 1
|
||||
|
||||
@@ -95,7 +95,8 @@ function ADCropPlan.choose(shortages, fields, usedFruits, yields, prices, dismis
|
||||
for _, candidate in ipairs(candidates) do
|
||||
if remaining <= 0 then break end
|
||||
local field = candidate.field
|
||||
local auto = field.chainFree == true and field.targetSource ~= "user"
|
||||
-- en mark slået fra i marklisten skiftes aldrig selv — den foreslås i stedet (godkend = slå til)
|
||||
local auto = field.chainFree == true and field.targetSource ~= "user" and field.enabled ~= false
|
||||
if auto or suggested < ADCropPlan.MAX_SUGGEST_PER_FRUIT then
|
||||
table.insert(actions, {fieldId = field.id, from = ADCropPlan.plannedFruit(field) or "", to = shortage.fruit,
|
||||
product = shortage.product, hectares = field.areaHa or 0, reason = shortage.key or shortage.fruit,
|
||||
|
||||
@@ -508,6 +508,13 @@ function ADFieldJobs.isFieldResumed(id)
|
||||
return (ADFieldJobs.state.resumed or {})[id] == true
|
||||
end
|
||||
|
||||
-- Til/Fra fra marklisten: om moden selv kører marken (ADFieldModel.setEnabled).
|
||||
function ADFieldJobs.setFieldEnabled(id, isOn)
|
||||
ADFieldJobs.setField(ADFieldModel.setEnabled(ADFieldJobs.getField(id), isOn))
|
||||
ADFieldJobs.save()
|
||||
ADFieldJobs.log(id, isOn and "slået til — moden kører marken" or "slået fra — moden starter intet selv")
|
||||
end
|
||||
|
||||
function ADFieldJobs.requestStart(id)
|
||||
ADFieldJobs.note(id, {startRequested = true})
|
||||
end
|
||||
|
||||
@@ -40,8 +40,9 @@ for stage in pairs(ADFieldModel.ROLES) do KNOWN_STAGES[stage] = true end
|
||||
KNOWN_STAGES.careLiming = true
|
||||
|
||||
local DEFAULT_PLAN = {
|
||||
-- auto som standard (brugerønske 5/10); "Gem uden at starte" i markguiden giver manuel
|
||||
mode = "auto", product = "auto", rake = false, rigs = 1, unloaders = 1,
|
||||
-- Til/Fra: "auto" = moden kører marken selv, "manual" = slået fra (kun [Start] sætter noget i gang).
|
||||
-- Fra som standard (brugerønske 10/10: et nyt kort må ikke tage alle marker, før spilleren slår dem til)
|
||||
mode = "manual", product = "auto", rake = false, rigs = 1, unloaders = 1,
|
||||
mulch = false, lime = true, soil = "auto", sow = false, sowFruit = "", roll = false,
|
||||
fertilize = true, weed = true, targetFruit = "", prepAfterMow = false, straw = "chop",
|
||||
-- kæde: marken er frigivet til produktionskæden; hvem der valgte målafgrøden ("user"|"chain"|"")
|
||||
@@ -186,6 +187,7 @@ function ADFieldModel.shouldStartBare(field, kind)
|
||||
if field.plan.targetFruit == nil or field.plan.targetFruit == "" then return false end
|
||||
-- kun fra idle: efter egen såning står marken "done" (nysået kan læses som bar) — ingen dobbelt-såning
|
||||
if field.held and not field.startRequested then return false end
|
||||
if field.plan.mode ~= "auto" and not field.startRequested then return false end
|
||||
return kind == "bare" and field.stage == "idle"
|
||||
end
|
||||
|
||||
@@ -337,9 +339,20 @@ function ADFieldModel.stop(field)
|
||||
copy.reason = nil
|
||||
-- stoppet af spilleren: en bar mark med mål-afgrøde starter ikke selv igen (Start eller nyt mål slipper)
|
||||
copy.held = true
|
||||
-- og marken slås fra: ellers står en stoppet høst "klar" og startes straks igen (in-game 10/10, nyt kort)
|
||||
copy.plan.mode = "manual"
|
||||
return copy
|
||||
end
|
||||
|
||||
-- Til/Fra fra marklisten. Ændrer kun om moden selv starter marken; et igangværende trin fortsætter (Stop stopper).
|
||||
function ADFieldModel.setEnabled(field, on)
|
||||
return ADFieldModel.with(field, {plan = {mode = on and "auto" or "manual"}})
|
||||
end
|
||||
|
||||
function ADFieldModel.isEnabled(field)
|
||||
return field ~= nil and field.plan ~= nil and field.plan.mode == "auto"
|
||||
end
|
||||
|
||||
-- Vejrfølsomme trin: afgrøde og skår skal være tørre (høst, slåning, vending, rivning, hø-opsamling).
|
||||
-- Jordbehandling, såning, pleje og ensilage-opsamling kan køre i regn.
|
||||
local WEATHER_STAGES = {harvesting = true, mowing = true, tedding = true, raking = true, strawCollecting = true, baling = true}
|
||||
@@ -509,7 +522,7 @@ function ADFieldModel.fromRecord(record)
|
||||
local field = ADFieldModel.newField(record.id)
|
||||
local plan = field.plan
|
||||
field.stage = KNOWN_STAGES[record.stage] and record.stage or "idle"
|
||||
plan.mode = record.mode == "manual" and "manual" or "auto"
|
||||
plan.mode = record.mode == "auto" and "auto" or "manual"
|
||||
-- etape 1 gemte "silage"/"hay"; ukendt -> auto
|
||||
plan.product = PRODUCTS[record.product] and record.product or "auto"
|
||||
plan.rake = readFlag(record.rake, false)
|
||||
|
||||
@@ -76,8 +76,6 @@ function ADFieldStorage.save(state)
|
||||
table.sort(resumedIds)
|
||||
xmlFile:setString(ADFieldStorage.ROOT .. "#resumed", table.concat(resumedIds, " "))
|
||||
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
|
||||
for vehicleId in pairs(state.fleet) do
|
||||
xmlFile:setString(string.format("%s.fleet.vehicle(%d)#id", ADFieldStorage.ROOT, vehicleIndex), vehicleId)
|
||||
@@ -116,11 +114,8 @@ function ADFieldStorage.load()
|
||||
result.resumed[tonumber(token) or token] = true
|
||||
end
|
||||
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)
|
||||
local field = ADFieldModel.fromRecord(ADFieldStorage.readRecord(xmlFile, key))
|
||||
if migrateAuto then field.plan.mode = "auto" end
|
||||
if field.id ~= nil then result.fields[field.id] = field end
|
||||
end)
|
||||
xmlFile:iterate(ADFieldStorage.ROOT .. ".fleet.vehicle", function(_, key)
|
||||
|
||||
@@ -142,11 +142,16 @@ function SmartPickupFrame:fillFieldRows(adEnv)
|
||||
local cells = self:addCellRow(self.fieldListPrefab, self:fieldCells(row))
|
||||
local fieldId = row.info.id
|
||||
if cells[1] ~= nil and cells[1].parent ~= nil then
|
||||
local actionCell = cells[7]
|
||||
local modeCell, statusCell, actionCell = cells[4], cells[5], cells[7]
|
||||
self:makeRowClickable(cells[1].parent, function(frame)
|
||||
-- klik på [Start]/[Stop]-feltet = handling (kun denne mark); ellers åbn redigeringsvinduet
|
||||
if frame.lastClickX ~= nil and actionCell ~= nil and actionCell.absPosition ~= nil and frame.lastClickX >= actionCell.absPosition[1] then
|
||||
-- klik på [Start]/[Stop]-feltet = handling (kun denne mark); [Til]/[Fra] = automatik;
|
||||
-- ellers åbn redigeringsvinduet
|
||||
local x = frame.lastClickX
|
||||
if x ~= nil and actionCell ~= nil and actionCell.absPosition ~= nil and x >= actionCell.absPosition[1] then
|
||||
frame:toggleField(fieldId)
|
||||
elseif x ~= nil and modeCell ~= nil and modeCell.absPosition ~= nil and statusCell ~= nil and statusCell.absPosition ~= nil
|
||||
and x >= modeCell.absPosition[1] and x < statusCell.absPosition[1] then
|
||||
frame:toggleFieldEnabled(fieldId)
|
||||
else
|
||||
frame.selectedFieldId = fieldId
|
||||
frame:openEditPanel("field", fieldId)
|
||||
@@ -376,6 +381,15 @@ function SmartPickupFrame:onClickFieldRow(state, data)
|
||||
end)
|
||||
end
|
||||
|
||||
-- Til/Fra for én mark (rækkens [Til]/[Fra]-felt).
|
||||
function SmartPickupFrame:toggleFieldEnabled(id)
|
||||
self:safe(function(frame)
|
||||
if id == nil then return end
|
||||
ADFieldJobs.setFieldEnabled(id, not ADFieldModel.isEnabled(ADFieldJobs.getField(id)))
|
||||
frame:requestRebuild()
|
||||
end)
|
||||
end
|
||||
|
||||
-- Start nu: pleje hvis marken trænger (og vokser), ellers hele kæden (høst/slå, eller klargøring på bar mark).
|
||||
function SmartPickupFrame:onClickFieldStartStop()
|
||||
self:toggleField(self.selectedFieldId)
|
||||
|
||||
@@ -124,17 +124,17 @@
|
||||
<text name="spu_field_plan_silage" text="Ensilage"/>
|
||||
<text name="spu_field_plan_hay" text="Hø"/>
|
||||
<text name="spu_field_plan_rake" text="riv"/>
|
||||
<text name="spu_field_mode_auto" text="Auto"/>
|
||||
<text name="spu_field_mode_manual" text="Manuel"/>
|
||||
<text name="spu_field_mode_auto" text="[Til]"/>
|
||||
<text name="spu_field_mode_manual" text="[Fra]"/>
|
||||
<text name="spu_field_notMowable" text="ikke græs/kløver"/>
|
||||
<text name="spu_field_scanning" text="Marker indlæses ... (én mark pr. sekund)"/>
|
||||
<text name="spu_field_hint" text="Klik på en mark for at se og rette dens opsætning."/>
|
||||
<text name="spu_field_hint" text="[Til]/[Fra]: skal moden selv køre marken (nye marker er fra). Klik på en mark for at se og rette dens opsætning."/>
|
||||
<text name="spu_field_fleetEmpty" text="! Markflåden står på "kun med flueben", men ingen maskiner har flueben — intet kan sendes ud. Åbn Markflåde og vælg "Brug alle ledige maskiner"."/>
|
||||
<text name="spu_field_showAll" text="Vis alle marker (%d skjult)"/>
|
||||
<text name="spu_col_field" text="Mark"/>
|
||||
<text name="spu_col_crop" text="Afgrøde"/>
|
||||
<text name="spu_col_plan" text="Plan"/>
|
||||
<text name="spu_col_mode" text="Kørsel"/>
|
||||
<text name="spu_col_mode" text="Auto"/>
|
||||
<text name="spu_field_section" text="— Mark F%d: %s —"/>
|
||||
<text name="spu_field_statusFull" text="Status: %s"/>
|
||||
<text name="spu_field_plan" text="Plan"/>
|
||||
|
||||
@@ -124,17 +124,17 @@
|
||||
<text name="spu_field_plan_silage" text="Silage"/>
|
||||
<text name="spu_field_plan_hay" text="Hay"/>
|
||||
<text name="spu_field_plan_rake" text="rake"/>
|
||||
<text name="spu_field_mode_auto" text="Auto"/>
|
||||
<text name="spu_field_mode_manual" text="Manual"/>
|
||||
<text name="spu_field_mode_auto" text="[On]"/>
|
||||
<text name="spu_field_mode_manual" text="[Off]"/>
|
||||
<text name="spu_field_notMowable" text="not grass/clover"/>
|
||||
<text name="spu_field_scanning" text="Loading fields ... (one field per second)"/>
|
||||
<text name="spu_field_hint" text="Click a field to see and change its setup."/>
|
||||
<text name="spu_field_hint" text="[On]/[Off]: should the mod run the field by itself (new fields are off). Click a field to see and change its setup."/>
|
||||
<text name="spu_field_fleetEmpty" text="! The field fleet is set to "only ticked", but no machine is ticked — nothing can be sent out. Open Field fleet and choose "Use all free machines"."/>
|
||||
<text name="spu_field_showAll" text="Show all fields (%d hidden)"/>
|
||||
<text name="spu_col_field" text="Field"/>
|
||||
<text name="spu_col_crop" text="Crop"/>
|
||||
<text name="spu_col_plan" text="Plan"/>
|
||||
<text name="spu_col_mode" text="Mode"/>
|
||||
<text name="spu_col_mode" text="Auto"/>
|
||||
<text name="spu_field_section" text="— Field F%d: %s —"/>
|
||||
<text name="spu_field_statusFull" text="Status: %s"/>
|
||||
<text name="spu_field_plan" text="Plan"/>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||
<modDesc descVersion="107">
|
||||
<author>masterdraco</author>
|
||||
<version>1.62.199.0</version>
|
||||
<version>1.62.200.0</version>
|
||||
<title>
|
||||
<en>AD Smart Pickup</en>
|
||||
</title>
|
||||
|
||||
Reference in New Issue
Block a user