[MOD 0.16 - 1.0] Realistic Electric Trains

Topics and discussion about specific mods
JAetherwing
Inserter
Inserter
Posts: 34
Joined: Sat Dec 29, 2018 2:51 pm
Contact:

[MOD 0.16 - 1.0] Realistic Electric Trains

Post by JAetherwing »

Realistic Electric Trains
Mod Portal Page: https://mods.factorio.com/mod/Realistic_Electric_Trains
Github: https://github.com/Scarabytes/FactorioR ... tricTrains

This mod is no longer being actively developed!

Features
  • Electric Locomotives, that do not require any fuel but run on electricity
  • Overhead lines that are required to distribute the power to the locomotives
  • Overhead line poles with and without integrated signals
  • English and German translation
Development status
I retired this project. This mod is trying to do things that are not meant to do with the Factorio API and it is a pain to find workarounds (It also hurts performance). Therefore, I decided to stop working on this project. If you want to take over the project, please message me.

If you are good with Blender (it's not hard to be better than I am) and want to help me out with the 3D Models of the locomotives, you totally can! Either PM me or create a pull request on Github, but please use the exact same camera and animation setting that I used in the sample files.

Notes on what's possible and what's not
  • As I used signals as the base entity for the poles it is unfortunately not possible to display the wire's reach and have that run-and-place-automatically feature from vanilla poles.
  • Unfortunately, due to the way I needed to implement the poles, neither the upgrade planner nor the FARL mod are compatible with this mod.
  • The hard cap to four modules in the modular locomotive will not be removed. It is not arbitrary - see the "internals" section for an explanation.
Issues/Bugs
If you should find any bugs in the mod, please report them over at github or the mod portal. I prefer useful, detailed bug reports, so please read this article first.

Changelog

See the mod portal page.


Tutorial
TUTORIAL

Internals
INTERNALS
Last edited by JAetherwing on Sat Sep 26, 2020 9:49 am, edited 12 times in total.
User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2920
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: [MOD 0.16] Realistic Electric Trains

Post by Optera »

This is by far the closest to a proper electric train I've seen in Factorio so far.

10 ticks for update seems still a bit fast. With the power graph updating at most every 5s you could potentially get away with running every 300th tick.
Even less if you don't care about uneven power graphs.
JAetherwing
Inserter
Inserter
Posts: 34
Joined: Sat Dec 29, 2018 2:51 pm
Contact:

Re: [MOD 0.16] Realistic Electric Trains

Post by JAetherwing »

Optera wrote: Mon Feb 18, 2019 6:32 pm10 ticks for update seems still a bit fast.
Honestly, I'm still experimenting quite a lot :)
I might change it to 60 or more ticks as I go.
User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2920
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: [MOD 0.16] Realistic Electric Trains

Post by Optera »

A good choice is to let users set the update frequency according to their needs. Since you might also need to adjust the fuel item it would have to be a startup setting though.

Toying around a little with it I noticed some shortcomings:
  • only signal poles keep circuit wires when blueprinting
  • fake entities show up in deconstruction planner
  • locomotive acceleration seems too low, especially compared to the boost rocket fuel and nuclear fuel provide
WraithCadmus
Burner Inserter
Burner Inserter
Posts: 6
Joined: Wed Mar 23, 2016 9:59 pm
Contact:

Re: [MOD 0.16] Realistic Electric Trains

Post by WraithCadmus »

Hmm, maybe hang a research off the higher levels of Braking Force to bump the acceleration?

EDIT: Also Optera knows more about trains that anyone else I know :D
User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2920
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: [MOD 0.16] Realistic Electric Trains

Post by Optera »

WraithCadmus wrote: Mon Feb 18, 2019 7:33 pm Hmm, maybe hang a research off the higher levels of Braking Force to bump the acceleration?

EDIT: Also Optera knows more about trains that anyone else I know :D
Sadly you can't add acceleration research.
Only thing you could do is swap the fuel item for one with a higher acceleration and top speed bonus after completing a research. But it wouldn't show the speed bonus in the bonus overview tab only directly on the locomotives.

Factorio has a fuel progression system making it hard to add locomotives with different fuels feel balanced alongside the base locomotive.
For my train overhaul mod I went and also rebalanced all fuel boni so locomotive upgrades had meaning.

No matter how much you know, there's always someone knowing more. ;)
JAetherwing
Inserter
Inserter
Posts: 34
Joined: Sat Dec 29, 2018 2:51 pm
Contact:

Re: [MOD 0.16] Realistic Electric Trains

Post by JAetherwing »

Optera wrote: Mon Feb 18, 2019 7:09 pm A good choice is to let users set the update frequency according to their needs. Since you might also need to adjust the fuel item it would have to be a startup setting though.

Toying around a little with it I noticed some shortcomings:
  • only signal poles keep circuit wires when blueprinting
  • fake entities show up in deconstruction planner
  • locomotive acceleration seems too low, especially compared to the boost rocket fuel and nuclear fuel provide
Good idea on the configurable update time, I'll add that to my ToDo list.
For the other points you mentioned, I'm honestly a little bit at a loss... I have actually posted a question about the blueprinted circuit wires in the Mod Help Forum, but didn't get any useful answer yet. The problem is that I use placer entities in order to get the rail signal placement indicators, but this then breaks ghost wire connections.. If you know how to fix that, I'd really appreciate any help :D
Finally, acceleration will be set a bit higher, but there'll be some higher tier locomotives anyway sooner or later.
User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2920
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: [MOD 0.16] Realistic Electric Trains

Post by Optera »

Preserving connections from blueprints is not straight forward, as you probably already guessed considering what you did to make the poles look nice. ;)

You have to allow the entity with connectors into blueprints and make it placable (bp mustn't turn red).
In your on_built_entity and on_robot_built_entity handler you then have to find the ghost entity belonging to the created pole and if it exists revive it otherwise create a new one like you currently do.

Caveats:
There's a lot terribly written mods out there messing with blueprints and ghost entities. My advice don't accommodate for their bad writing and have them fix their code. Creative Mode for example has an interface to add ghosts it should never touch into a blacklist.
yukinyaa
Burner Inserter
Burner Inserter
Posts: 12
Joined: Tue Dec 19, 2017 5:14 pm
Contact:

Re: [MOD 0.16] Realistic Electric Trains

Post by yukinyaa »

hey hey github link is broken :(
JAetherwing
Inserter
Inserter
Posts: 34
Joined: Sat Dec 29, 2018 2:51 pm
Contact:

Re: [MOD 0.16] Realistic Electric Trains

Post by JAetherwing »

Uhm... That shouldn't be the case. The link works totally fine for me, even from a different computer. What error do you get?
snooozer
Burner Inserter
Burner Inserter
Posts: 10
Joined: Tue Feb 19, 2019 2:28 pm
Contact:

Re: [MOD 0.16] Realistic Electric Trains

Post by snooozer »

Thanks for the awesome mod!

github works now, was just giving a 404 (thanks).

Code: Select all

As I used signals as the base entity for the poles it is unfortunately not possible to display the wire's reach and have that run-and-place-automatically feature from vanilla poles.
This might be a very long fetched idea, but rail signals could be connected with red/green wires. Would it be possible to achieve a visual wire feedback system with 'listening to whenever an electric pole is being placed it is also automatically connected with a custom wire'?. That wire should have a range that can be modified and thus at least should achieve some visual feedback. Not sure how much fiddeling this would be, especially since the poles around the corner have a slightly smaller range...

Just an idea I guess, maybe it would be worth to just wait out 0.17 :)
timer67
Inserter
Inserter
Posts: 40
Joined: Sun Apr 30, 2017 7:01 pm
Contact:

Re: [MOD 0.16] Realistic Electric Trains

Post by timer67 »

Hey, was enjoying this mod in my singleplayer game but it seems to be causing instant desync issues in Multiplayer :(
JAetherwing
Inserter
Inserter
Posts: 34
Joined: Sat Dec 29, 2018 2:51 pm
Contact:

Re: [MOD 0.16] Realistic Electric Trains

Post by JAetherwing »

I'd appreciate a little bit more information about the problem you face in order to resolve it.

I know it's cliché, but "It works on my machine"
User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2920
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: [MOD 0.16] Realistic Electric Trains

Post by Optera »

Debugging MP desyncs is a royal pain. Unlike other bugs where we see exactly what line caused it, all information we ever get from desync reports is it happened.

Check if data anywhere in a local table or variable can change during runtime and might be different when players join running games.
timer67
Inserter
Inserter
Posts: 40
Joined: Sun Apr 30, 2017 7:01 pm
Contact:

Re: [MOD 0.16] Realistic Electric Trains

Post by timer67 »

Yeah, there is literally no error.
Just <Player> Desynced.

Same every time on a connection.
eduran
Filter Inserter
Filter Inserter
Posts: 344
Joined: Fri May 09, 2014 2:52 pm
Contact:

Re: [MOD 0.16] Realistic Electric Trains

Post by eduran »

Your on_tick handler looks like a good suspect for the desync issue.

Code: Select all

local dummy_fuel
local dummy_fuel_value
local max_transfer = config.loco_max_energy_transfer_val

function on_tick(event)

  if event.tick % 10 == 0 then

    if not dummy_fuel then
      dummy_fuel = game.item_prototypes["ret-dummy-fuel-1"]
      dummy_fuel_value = dummy_fuel.fuel_value
    end
    .......
Player A creates the game, triggers on tick and dummy_fuel is set -> Player B joins on one of the 9/10 ticks without update -> at the end of that tick, dummy_fuel and dummy_fuel_value are different for player A and B -> desync
JAetherwing
Inserter
Inserter
Posts: 34
Joined: Sat Dec 29, 2018 2:51 pm
Contact:

Re: [MOD 0.16] Realistic Electric Trains

Post by JAetherwing »

I thought so too, but then I apparently was extremely lucky to not get desynced for a few dozen times.

Are local variables included in the crc check though? And if so, where should I cache the prototypes instead? I can't access the game object in the on_load event for instance.

I can (and probably will) move the current assignment out if the if block that checks the tick number though.
Mohit
Manual Inserter
Manual Inserter
Posts: 2
Joined: Sun May 21, 2017 8:53 am
Contact:

Re: [MOD 0.16] Realistic Electric Trains

Post by Mohit »

Hello, your mod is that what i was looking for for longer time here in factorio, but you should try to add soudn to locomotive like is in nuclear locomotives, that real electric train engine. Second thing which would be better is to have possibility to place those electric rail poles in some way like normal electric poles, or similiar way, its hard to know where exactly put that pole :)
One more thing try add higher tiers of locomotive or something electric trains have better speed usually than diesel engine locomotives and more power.
eduran
Filter Inserter
Filter Inserter
Posts: 344
Joined: Fri May 09, 2014 2:52 pm
Contact:

Re: [MOD 0.16] Realistic Electric Trains

Post by eduran »

You cannot desync in singleplayer, if that is what you tested. And yes, local variables are included.

I would probably store it in global. Moving the assignment directly into on_tick should also do the trick, with the downside of performing a mostly useless check on every tick (which is not a big deal).
psihius
Fast Inserter
Fast Inserter
Posts: 192
Joined: Mon Dec 15, 2014 12:47 am
Contact:

Re: [MOD 0.16] Realistic Electric Trains

Post by psihius »

You can also use `on_nth_tick` event instead of doing division in the `if` statement every tick :)
Post Reply

Return to “Mods”