diff --git a/FS25_ADSmartPickup/adOutbound.lua b/FS25_ADSmartPickup/adOutbound.lua index 63af915..3fd84ac 100644 --- a/FS25_ADSmartPickup/adOutbound.lua +++ b/FS25_ADSmartPickup/adOutbound.lua @@ -657,6 +657,31 @@ function ADOutbound.beforeUnloadUpdate(adEnv, task, dt) return false end +-- Efter pålæsning: autoload-bil med tur får stropperne spændt, så lasten ikke tabes på vejen +-- (AutoDrive/UAL sætter dem ikke selv på igen efter vores løsning før forrige aflæsning). +function ADOutbound.strapAfterLoading(adEnv, task) + local vehicle = task.vehicle + local state = trips[vehicle] + if state == nil then + return + end + local _, hasAutoload = getVehicleCapacity(adEnv, vehicle) + if not hasAutoload then + return + end + local strapped = 0 + for _, unit in ipairs(task.trailers or {}) do + if unit.setAllTensionBeltsActive ~= nil then + pcall(unit.setAllTensionBeltsActive, unit, true, false) + strapped = strapped + 1 + end + end + state.unstrapped = false + if strapped > 0 then + Logging.info(ADOutbound.LOG_PREFIX .. "'%s': stropper spændt efter pålæsning", tostring(vehicle:getName())) + end +end + -- true = opsamlingsrunden fortsætter til næste kilde (original finished springes over). function ADOutbound.beforeLoadFinished(adEnv, task) local vehicle = task.vehicle @@ -745,7 +770,10 @@ function ADOutbound.install(adEnv) elseif continueRound then return end - return originalFinished(self) + local result = originalFinished(self) + -- autoload-bil kører nu fra kilden: stropperne SKAL på (de løsnes 25 m før aflæsningen) + pcall(ADOutbound.strapAfterLoading, adEnv, self) + return result end end diff --git a/FS25_ADSmartPickup/modDesc.xml b/FS25_ADSmartPickup/modDesc.xml index 1e69dfd..7144a6d 100644 --- a/FS25_ADSmartPickup/modDesc.xml +++ b/FS25_ADSmartPickup/modDesc.xml @@ -1,7 +1,7 @@ masterdraco - 1.12.17.0 + 1.12.18.0 <en>AD Smart Pickup</en> diff --git a/tests/test_adOutbound.lua b/tests/test_adOutbound.lua index de8ddb6..0266f2b 100644 --- a/tests/test_adOutbound.lua +++ b/tests/test_adOutbound.lua @@ -523,6 +523,25 @@ check("O10 original finished kaldt", calls.finished, 1) adEnv.UnloadAtDestinationTask.update = function(self, dt) calls.unload = (calls.unload or 0) + 1 end ADOutbound.install(adEnv) check("O10 unload-wrap ikke installeret dobbelt", adEnv.UnloadAtDestinationTask.update ~= nil, true) +-- O24: stropperne spændes igen når pålæsningen er færdig (de blev løsnet 25 m før forrige salg; +-- in-game 23/9: Dragon tabte paller på vejen to gange) +local v24 = newVehicle("Dragon5", 100, 0, 1, true) +v24.carriable = {} +v24.trailers[1].setAllTensionBeltsActive = function(self, active) self.beltsActive = active end +runs[v24] = outboundRun(27, {3}, {{fillType = "STRAW_BASKET", policy = "sell"}}) +sources[3].stored[BASKET] = 3 +quotes["selling station"][BASKET] = {percent = 95, price = 1} +ADOutbound.choosePickup(adEnv, v24) +local task24 = newTask(v24, 3) +v24.trailers.level = 3 +adEnv.LoadAtDestinationTask.finished(task24) +check("O24 stropper spændt efter pålæsning", v24.trailers[1].beltsActive, true) +check("O24 tur planlagt", ADOutbound.getTripFor(v24) ~= nil, true) +check("O24 original finished kaldt", calls.finished, 2) +local v24b = newVehicle("Tip4", 0, 0, 20000) +v24b.trailers[1].setAllTensionBeltsActive = function(self, active) self.beltsActive = active end +adEnv.LoadAtDestinationTask.finished(newTask(v24b, 1)) +check("O24 tipvogn uden tur: rører ikke stropper", v24b.trailers[1].beltsActive, nil) print(failures == 0 and "\nALLE TESTS OK" or ("\n" .. failures .. " FEJL")) os.exit(failures == 0 and 0 or 1)