Train Skip Fulfilled Station


Changes trains behavior so they will skip a station if the "wait until" condition is already met

Content
2 years ago
0.15 - 1.1
4.54K
Trains

g Driving in circles when all conditions are fulfilled

2 years ago

First of all thank you for writing this mod :) I think it is allows for a very intuitive way of scaling trains!

I noticed some strange behavior and tried to come up with a small example (blueprint string attached below).
What happens:
If a train has only two stops A and B both with an already fulfilled condition it starts driving in circles from A to B and back.

What I would expect:
The train should not start driving to another stop if the condition is already fulfilled.

I hope my expectation aligns with your idea of the mod and if so I would also be happy to provide a patch if I have a bit of time to get into the code.

Blueprint string:
0eNrNl82O2yAQgN+Fsx0ZMMbOsYe+RLWyiEOySDZEGGebRnn3Drbj7GbpJrSX5gQBvplhfhif0aYd5MEq7dD6jFRjdI/WP86oV3stWv+fOx0kWiPlZIcSpEXnZ1aoFl0SpPRW/kRrfHlJkNROOSWn8+PkVOuh20gLG5aT/bDpnXDKaKAdTK/GIcgBTIoxS9AJBoReLsknClkospWNs6pJpZZ2f0pBf2l3opFfQjFovBl2O2nrXv0CDs6WX0AcXcQ5sFenvTOHr/i4Av5WWVBtXC4SdDV1jb6ZDZzthB5EW4+8vm5Vp5y/vc+y80W20julYSltXmXvgvLJatFgxUavTEfqXjqn9L73W63szFHWA6y1cFlyW3uXwtJOtL1M0PT35L1ZtB6aVgqb7gbZguDGDD5MwJed2fp14VJYH5W6BULIcWyxZgfbwVu9tCDsgTElGBOAFQusGexRbtMxGAMoks2g4s4vASi/Bah3zv7V/RG7uJt/xJIAtnxWV/wHXWkAWj2vK6Ezln7E8gDWq/AsN+NhbiiU8S35G2H3Jn0T+3D2E7Yqs4yXMJjx2YqwcQ5ijFVAnvMpWzGec47zgpYc0pjgipOCFf6k0kfYaCwQ9NC2IZXI0zFUXDV5wlD6LDXLF2qIc0v+1jSmM04dZVi5VcnwZLTH0RWjwbvKy5JUlNCMUcqqqmT0emyuAeePub4Oll/MIgJvDpBgBuMiItLoVyAe6cc7L+YhZhnpxTsmCzHjU5Y+ppIsshIWj4sAwZEVq3hcBAmJLiz0cRUkNLpkP1GwSR7xVPH5qSrHV/dBXBEW86Rf0f/pg06KuN7orjMi7zuj71boJqY3Ivyf+kCM75wV1RSSMq6VhRfSN8c9uHo7tHN3fCvrfo7zdxum7vvT5bwJ5WrozrejkIkCjIOwsp47dOODdB7L7uBOCHyXnD/1oH+LevF2jJ8B63dfDQk6QpBNXi1xzivC86IiRVZeLr8BpGQHIw==

2 years ago

After going through the code a bit and trying to figure out why something doesn't work as I expected it to I noticed that
train.schedule.current
Is sometimes used as if it contains the station where the train is currently parked, but that is not actually the value saved inside. The moment the events fire the value is the station the train is going to drive to if this mod does not decide anything else.

2 years ago

Hello
Thank you for feedback and blueprint was very helpful. I am not sure if there is easy way to prevent train from dispatching when all stations fulfilled.
Please share if you have any ideas

2 years ago

Hi :)
I tinkered around with the code a bit and came up with something that is not the optimal solution. Since I wanted to tinker arohnd with Train behavior anyway I also packaged it into a mod: https://mods.factorio.com/mod/BetterTrainBehavior

The solution is basically putting the train on manual mode, wait a fixed amount of time and checking stations again. In hindsight however I think a better solution would be to add a fixed "and time passed" condition to the train stop which is then also removed again by the mod when the train actually leaves the station.
Feel free to use whatever you find useful from my mod as it is based on yours anyway.

New response