Scenario #1: Train is loading with cargo when the user moves a different job to the top of the queue.
Scenario #2: Loading wood, stone, etc from the outpost build site to return it to base.
The second situation is potentially the easiest. If the train schedule includes a trash unload stop before the ME loading stop, it can arrive at the loading station fresh and empty.
That arrangement could also work for the first case, but you'd have to be careful at the unloads to use filter inserters and your circuit conditions to only unload what you want. For that trip, the wagon may work at reduced capacity since it'd be partially full of stuff for a now-postponed job. However, once it continues the schedule, the trash stop will take care of it. It's not the most elegant solution, but it works within the current limits of the mod and game.
I just spent some time trying to improve on that by adding a typical vanilla trash circuit on the other side of the wagons. (take what you want, invert the count, read train contents and combine the counts, send any count > 0 to filter inserters so they unload whatever's not part of the request.) Then I discovered that the ME Combinator stops outputting the signal for an item as soon as it is received, even when it's on the train. D'oh. Of course it does. It'd have to. That kinda puts a stop to the idea of unloading everything that isn't part of the current request since the mod (rightly) considers everything on the train to be no longer part of the current request.
I'm not sure if there is a more elegant way to do it that doesn't involve too much code bloat. :/
I thought of maybe the ME Combinator could pulse a special signal when a new job moves to the top. With some circuitry (maybe an RS-NOR latch and timer) one could stop loading, unload the train, then start loading again. That feels a bit "ugh" to be honest.
It also doesn't cover the simple task of unloading the trees and other construction debris.
I guess you could default-lock the loading inserters, and send signal to a timer when a train arrives. Timer gives unloaders enough time to unload, then locks unloaders while unlocking loaders. Again, kinda ugh.
Another option might be that a manual change in the queue might have is, if the current job gets manually changed and a train is in the loading station, first send it a new schedule that tells it to head to the trash stop and then the ME loading station. Even if it is currently at the ME loading station, it should head out, empty, and return. Yeah that might not be any better than simply letting it haul the outdated load to the new job site and then stopping by trash unload on the way to the ME load after all.
I dunno. Just kinda brainstorming and thinking out loud. Maybe it'll spark ideas/conversation. It's a bit of a bummer that I can't seem to figure out a combination loading/trash stop. Does anyone have any slick suggestions?
Thanks for the mod LordKTor. You're a legand. :)