Faster trains and corridors
Posted: Thu Jan 30, 2020 3:36 pm
Hello
I've got to the phase where all my outposts and parts of the factory span across large part of the map and it takes a long time to ride a train from one end to the other. And I've noticed that you get the locomotive very early (green science) and use the very same locomotive to the very end, only with somewhat better fuel. So, I was thinking if there was something that could be done with that.
And indeed, there are mods that add faster trains. However, they add just that, in a very boring way, no challenge to them ‒ they are faster and more expensive and that's it and the price of few locomotives doesn't really matter at this phase of the game, as there are very few anyway.
So my idea is to have a locomotive with a faster max speed (but maybe worse acceleration, it would be suitable for long journeys but not for these local stop-to-stop jumps inside a small factory). I'd also add next tier of rails (maybe one that would use concrete instead of stones). The locomotive could go at its max speed only on these new better rails and only if there were no curves. That would present the challenge of building the corridor that doesn't include turns, using the better rails (more expensive ones). On normal rails or curves, it would be able to go the normal ~300km/h or so. That would also make it look more realistic (these extra-fast trains need higher quality rails to go fast).
What do you think about the idea?
I was actually thinking of trying to make the mod. I know lua, and I program, but I haven't done any factorio mods yet, so a little push in the right direction could probably save me a lot of time.
What I've researched so far:
I've got to the phase where all my outposts and parts of the factory span across large part of the map and it takes a long time to ride a train from one end to the other. And I've noticed that you get the locomotive very early (green science) and use the very same locomotive to the very end, only with somewhat better fuel. So, I was thinking if there was something that could be done with that.
And indeed, there are mods that add faster trains. However, they add just that, in a very boring way, no challenge to them ‒ they are faster and more expensive and that's it and the price of few locomotives doesn't really matter at this phase of the game, as there are very few anyway.
So my idea is to have a locomotive with a faster max speed (but maybe worse acceleration, it would be suitable for long journeys but not for these local stop-to-stop jumps inside a small factory). I'd also add next tier of rails (maybe one that would use concrete instead of stones). The locomotive could go at its max speed only on these new better rails and only if there were no curves. That would present the challenge of building the corridor that doesn't include turns, using the better rails (more expensive ones). On normal rails or curves, it would be able to go the normal ~300km/h or so. That would also make it look more realistic (these extra-fast trains need higher quality rails to go fast).
What do you think about the idea?
I was actually thinking of trying to make the mod. I know lua, and I program, but I haven't done any factorio mods yet, so a little push in the right direction could probably save me a lot of time.
What I've researched so far:
- I'd probably just create a copy of the ordinary locomotive and tweak some parameters to it, to create the new prototype (I hope I'm not confusing the terminology).
- Similar with the rails.
- Then, in the on_tick hook, I'd go through all the trains and check if they are not going too fast according to where they are and brake them a little if needed. The speed property of a train is read/write.
- I probably want to slow down *before* the turns or ordinary rails. So I'd have to read the path property, find where the train is on that and look a bit ahead. That should be possible, maybe a bit tedious.
- What are downsides of this approach? Will I break something? Is there a better hook than on_tick, one that wouldn't have to run as often?
- Will my new rails integrate with the rail planner?
- Will they integrate with upgrade planner? How do I make them „the next tier“?
- How do I know how much a train can decelerate right now? There are these „braking force“ researches and I assume I can read if these were researched. But there are other mods that add more levels of these or tweak by how much the braking force is improved, so I'd really prefer to have an authoritative number, the same one the engine uses for slowing down before eg. signals.
- Would it be possible to make the path finding algorithm prefer fastest paths instead of shortest ones?