Project Cybersyn - Logistics Train Dispatcher


Creates a feature-rich train logistics network through cybernetic combinators. With just this mod you can coordinate the economic inputs and outputs of your entire megabase.

Content
3 days ago
1.1 - 2.0
25.6K
Logistics Trains Circuit network

i extending refuel function

1 year, 11 months ago

I would like to suggest a way to allow centralised fueling station for people who implements distributed depot.

It can be another dropdown option for the combinator (something like "fuel station control").
Depot control can read input signal of "use fuel station" to decide whether to include a fuel stop in the schedule.
"use fuel station" will alter the fuel check decision - the system will now send the train to fuel station to refuel instead of the depot.
The fuel stop can be implemented like in Train Control Signals where an internal virtual signal is placed in front of the station name - making it an invalid stop so trains will just skip it if there is enough fuel. Fuel checks will decide whether to rename the station back into the proper fuel station name.

Or alternatively, is it possible to raise events for each created schedule so that other mods can modify the schedule?

1 year, 11 months ago

such interface will also be useful for mods like https://mods.factorio.com/mod/ltn-cleanup if they decide to implement one for cybersyn

1 year, 11 months ago

A modding interface will be in the next update. I also very much like your idea for refueling depots/stations. My idea for them is to add a checkbox to every depot that says whether it provides fuel or not. If not trains will add to their schedule a detour to the nearest depot that does provide fuel when they are running low.

1 year, 11 months ago

version 1.0.8 now has a remote-interface.

1 year, 11 months ago

the new update looks neat, thanks.

My idea for them is to add a checkbox to every depot that says whether it provides fuel or not. If not trains will add to their schedule a detour to the nearest depot that does provide fuel when they are running low.

That does sound like a good way to implement it. Possible to attach Auto-list function for different loco configurations?

1 year, 11 months ago

that's actually a great idea. I'll deny trains that have cargo wagons trying to park where a refueling inserter is

1 year, 11 months ago

btw, on the helper functions in remote-interface, afaik anything returned through remote.call is a copy (except factorio objects maybe?). I have tried writing data to the Cybersyn train state returned from get_train and then observe it on next Cybersyn tick - the changes made in my mod did not propagate to the state in Cybersyn.

1 year, 11 months ago

on the other hand, I have noticed that the train that got redirected in my mod does not immediately get a new delivery after the refuel and has to go back to the depot before being assigned a new schedule. Is there something I can work on to restore the behaviour?

1 year, 11 months ago
(updated 1 year, 11 months ago)

oh really? that's incredibly annoying, unnecessary and undocumented of factorio. I will hack in some more internal access to the mod because I really thought factorio was providing it already.

So you want to use the function "add_available_train". if "add_available_train" is called on a train, that train from that moment onwards can do depot bypass, be sure the train has completed its delivery before calling it. I'm honestly surprised it is not working already, thus overriding the refueling order you insert with a new delivery.

1 year, 11 months ago

Ah I see, you ask users to disable the refueling threshold. Calling "add_available_train" will still work.

1 year, 11 months ago
(updated 1 year, 11 months ago)

So you want to use the function "add_available_train". if "add_available_train" is called on a train, that train from that moment onwards can do depot bypass, be sure the train has completed its delivery before calling it. I'm honestly surprised it is not working already, thus overriding the refueling order you insert with a new delivery.

Thanks for the advice. I found out that even without disabling refueling threshold (at 0.5), the train still chose to return to the depot after refueling - maybe it ceased to become available at some point after the schedule has been modified?

Anyway I got the behaviour to work again by calling add_available_train after the train exits wait_station from a refuel station. Hence now my mod needs to keep track of trains that waited at a refuel station because there is no other events that tells me refueling is complete/a train has just left refuel station. [https://github.com/loneguardian/TCS-Refuel-Compatibility/blob/master/control.lua#L80]

Or maybe I should just wait for your implementation rofl

1 year, 11 months ago
(updated 1 year, 11 months ago)

Alternatively, is it possible for your mod to implement a pre-dispatch event that allows any other mods who wish to alter the schedule to do a callback? The aim is to allow Cybersyn to maintain its vanilla behaviour (in this case, the add_available_train call after a train completes its delivery).

  1. Pre-dispatch event will announce the train_id and schedule records.
  2. Any mod who wishes to modify it will callback with the modifications.
  3. Cybersyn will verify the schedule modification and then finalise it and dispatch the train. add_available_train will be called by Cybersyn after all stops have been served.

I see the architecture above suits the need for a clean-up mod too (or mods who want to modify wait conditions for stops), but a clean-up mod will probably have to modify the schedule only after delivery has been completed.

P/S: I am suggesting a pre-dispatch event to minimise the amount of path revalidating a train has to do with each schedule change.

New response