feat(flows): traktor i et kørende flow startes når spilleren selv har kørt den til Connect og koblet dens vogn på (v1.56.2.0)

This commit is contained in:
2026-09-29 14:58:10 +02:00
parent be11283ba7
commit fece920028
4 changed files with 39 additions and 5 deletions
+22
View File
@@ -39,6 +39,11 @@ function ADFlowWagons.retryFetch(reason, retries)
return tostring(reason):find("^stoppedAway") ~= nil and (retries or 0) < ADFlowWagons.FETCH_RETRIES
end
-- s = {flowRunning, ownWagon, adActive} -> start traktoren efter spillerens egen påkobling?
function ADFlowWagons.startAfterManualAttach(s)
return s.flowRunning == true and s.ownWagon == true and not s.adActive
end
-- Hvorfor "wait" (til loggen). s som startAction.
function ADFlowWagons.waitReason(s)
if s.tractorBusy then return "tractorBusy" end
@@ -421,6 +426,22 @@ function ADFlowWagons.homeVehicle(adEnv, vehicle, runName)
end
end
-- ADHitch: spilleren har selv kørt traktoren til Connect og koblet på.
function ADFlowWagons.onManualAttach(adEnv, vehicle, wagon)
local run = ADRunsController.getRunForVehicle(vehicle)
if run == nil then return end
local tractorId = ADRunsController.getVehicleId(vehicle)
local wagonId = wagon ~= nil and ADRunsController.getVehicleId(wagon) or nil
local remembered = (run.wagons or {})[tractorId]
local module = vehicle.ad ~= nil and vehicle.ad.stateModule or nil
if not ADFlowWagons.startAfterManualAttach({flowRunning = not run.stopped and ADRunsController.runningRuns[run.id] == true,
ownWagon = wagonId ~= nil and (remembered == nil or remembered == wagonId),
adActive = module ~= nil and module:isActive()}) then return end
fetchRetries[vehicle], waiting[vehicle] = nil, nil
Logging.info(ADFlowWagons.LOG_PREFIX .. "flow '%s': '%s' har selv hentet sin vogn — startes", tostring(run.name), tostring(ADRuns.vehicleLabel(vehicle)))
ADRunsController.startVehicle(adEnv, run, vehicle)
end
function ADFlowWagons.isEmptying(vehicle)
return emptying[vehicle] ~= nil
end
@@ -567,6 +588,7 @@ local emptyTimer = 0
function ADFlowWagons.tick(adEnv, dt)
if adEnv == nil or ADRunsController.store == nil then return end
if ADHitch ~= nil and ADHitch.onManualAttach == nil then ADHitch.onManualAttach = ADFlowWagons.onManualAttach end
nowMs = nowMs + dt
emptyTimer = emptyTimer + dt
if emptyTimer >= 2000 then