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:
@@ -473,7 +473,7 @@ end
|
||||
local DONE_TEXT = {attach = "koblede '%s' på", detach = "koblede '%s' af", arrive = "er fremme%s"}
|
||||
local FAIL_TEXT = {attach = "kunne ikke koble på", detach = "kunne ikke koble af", arrive = "nåede ikke frem"}
|
||||
|
||||
local function finish(vehicle, job, ok, detail)
|
||||
local function finish(vehicle, job, ok, detail, adEnv)
|
||||
jobs[vehicle] = nil
|
||||
if ok then
|
||||
Logging.info(ADHitch.LOG_PREFIX .. "'%s' " .. DONE_TEXT[job.action] .. " ved '%s'", vehicleName(vehicle),
|
||||
@@ -482,7 +482,13 @@ local function finish(vehicle, job, ok, detail)
|
||||
Logging.warning(ADHitch.LOG_PREFIX .. "'%s' %s ved '%s': %s", vehicleName(vehicle), FAIL_TEXT[job.action],
|
||||
job.markerName, tostring(detail))
|
||||
end
|
||||
if job.onDone ~= nil then pcall(job.onDone, vehicle, ok, detail) end
|
||||
if job.onDone ~= nil then
|
||||
pcall(job.onDone, vehicle, ok, detail)
|
||||
elseif ok and job.action == "attach" and ADHitch.onManualAttach ~= nil then
|
||||
-- spillerens egen tur til Connect: lad fx flowet starte traktoren bagefter
|
||||
local okHook, err = pcall(ADHitch.onManualAttach, adEnv, vehicle, detail)
|
||||
if not okHook then Logging.warning(ADHitch.LOG_PREFIX .. "efter manuel kobling: %s", tostring(err)) end
|
||||
end
|
||||
end
|
||||
|
||||
local ACTIONS = {attach = ADHitch.tryAttach, detach = ADHitch.tryDetach, arrive = function() return true, "" end}
|
||||
@@ -508,9 +514,9 @@ function ADHitch.tick(adEnv, dt)
|
||||
if job.crept then state.arriveDistance = ADHitch.ARRIVE_DISTANCE + ADHitch.CREPT_EXTRA_DISTANCE end
|
||||
ADHitch.step(job, state, elapsed, succeeded)
|
||||
if job.state == "done" then
|
||||
finish(vehicle, job, true, detail)
|
||||
finish(vehicle, job, true, detail, adEnv)
|
||||
elseif job.state == "failed" then
|
||||
finish(vehicle, job, false, job.lastReason or job.reason)
|
||||
finish(vehicle, job, false, job.lastReason or job.reason, adEnv)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user