feat: udkørsel koblet på AutoDrive-hooks; Wait-logik springer udkørsels-traktorer over; v1.12.0.0
This commit is contained in:
@@ -1067,5 +1067,43 @@ manager:getNextPickup(chatty, false); manager:getNextPickup(chatty, false)
|
||||
check("L6 gentaget valg logges én gang", #logLines, 1)
|
||||
check("L6 loggen viser eget lager", logLines[1]:find("eget lager", 1, true) ~= nil, true)
|
||||
|
||||
-- X: udkørsel koblet på getNextPickup-wrap'en og Wait-logikken
|
||||
resetWorld()
|
||||
addMarker(1, "Suger Load", "Pickup points", 0, 0); table.insert(stations, makeStation(101, 0, 15, {[WHEAT] = 1000}))
|
||||
addMarker(2, "Wait 3", "General Wait", 100, 0)
|
||||
local outboundDriver = makeDriver(markers[1], {WHEAT})
|
||||
local outboundCalls, outboundChoice, outboundError = 0, nil, false
|
||||
ADOutbound = {
|
||||
isOutboundVehicle = function(vehicle) return vehicle == outboundDriver end,
|
||||
choosePickup = function(adEnv, vehicle) outboundCalls = outboundCalls + 1; if outboundError then error("boom") end return outboundChoice end,
|
||||
releaseInactive = function() end,
|
||||
install = function() end,
|
||||
}
|
||||
outboundChoice = {markerIndex = markers[1].markerIndex, markerName = "Suger Load", group = "Pickup points", station = stations[1], fillTypes = {WHEAT}, fillType = WHEAT}
|
||||
check("X1 udkørsel: kilden vælges af ADOutbound", manager:getNextPickup(outboundDriver, false), markers[1].markerIndex)
|
||||
check("X1 ADOutbound spurgt", outboundCalls, 1)
|
||||
check("X1 greb sat (station kendt)", ADSmartPickup.getActivePickup(outboundDriver) ~= nil, true)
|
||||
outboundChoice = {markerIndex = markers[2].markerIndex, markerName = "Wait 3", group = "General Wait", station = nil, fillTypes = {}, fillType = nil}
|
||||
check("X1 Wait-markør uden station", manager:getNextPickup(outboundDriver, false), markers[2].markerIndex)
|
||||
check("X1 intet greb uden station", ADSmartPickup.getActivePickup(outboundDriver), nil)
|
||||
outboundChoice = nil
|
||||
check("X1 nil -> AutoDrives original", manager:getNextPickup(outboundDriver, false), "ORIGINAL")
|
||||
outboundError = true
|
||||
check("X1 fejl -> AutoDrives original", manager:getNextPickup(outboundDriver, false), "ORIGINAL")
|
||||
outboundError = false
|
||||
-- setActivePickup (bruges af opsamlingsrunden) opdaterer grebet direkte
|
||||
ADSmartPickup.setActivePickup(outboundDriver, {station = stations[1], fillTypes = {WHEAT}, markerName = "Suger Load", fillType = WHEAT})
|
||||
check("X2 setActivePickup", ADSmartPickup.getActivePickup(outboundDriver).markerName, "Suger Load")
|
||||
ADSmartPickup.setActivePickup(outboundDriver, nil)
|
||||
check("X2 setActivePickup nil rydder", ADSmartPickup.getActivePickup(outboundDriver), nil)
|
||||
-- Wait-logikken springer udkørsels-traktorer over (rører ikke vognens indhold)
|
||||
local originalUnits = FS25_AutoDrive.AutoDrive.getAllDischargeableUnits
|
||||
FS25_AutoDrive.AutoDrive.getAllDischargeableUnits = function() error("må ikke kaldes for udkørsel") end
|
||||
outboundDriver.ad.drivePathModule = {isTargetReached = function() return true end}
|
||||
local okWait = pcall(ADUnloadWait.beforeUpdate, FS25_AutoDrive, {vehicle = outboundDriver, destinationID = 1}, 16)
|
||||
check("X3 Wait-logik springer udkørsel over", okWait, true)
|
||||
FS25_AutoDrive.AutoDrive.getAllDischargeableUnits = originalUnits
|
||||
ADOutbound = nil
|
||||
|
||||
print(failures == 0 and "\nALLE TESTS OK" or ("\n" .. failures .. " FEJL"))
|
||||
os.exit(failures == 0 and 0 or 1)
|
||||
|
||||
Reference in New Issue
Block a user