Electric Trains


Adds electric trains.

Content
11 days ago
0.16 - 2.0
49.7K
Trains

i Compatibility with Multiple Unit Train Control

3 years ago

I really like the mod! I just tested compatibility with my mod, Multiple Unit Train Control and found that the electric charging logic does not work for the "electric-locomotive-mu" entity mine creates. I put "electric-locomotive" on the blacklist so my mod does not break yours. If you are interested in adding compatibility features, let me know!

3 years ago
(updated 3 years ago)

Hey there, I'm glad you like the mod. The charging code only recognises the mod's own locomotive entity. It would be fairly simple to modify; if you want to test it out, modify line 100 in my control.lua to read:

if w.name == "electric-locomotive" or w.name == "electric-locomotive-mu" then

It looks like the fuel balancing code should be okay, but the train replacement code might cause issues, if a change happens while mine's in the process of recharging. I do redundant checks as failsafes so I think it will fail gracefully and remove orphaned entities, but who knows.

Edit: It occurs to me that you probably know all that already. I can probably make my mod more flexible too, so that it can play more nicely with yours and any others out there that want to add variants or use my charging mechanics (unlikely as that may be). I'd be interested in doing that, sure, though I think it might take some significant restructuring of mine.

3 years ago

Yes, it will be a bit of work to make a global table of names of locomotives that can be charged. Then update that table in on_init, on_configuration_changed, and in a remote interface "register electric locomotive" function.

Might I also suggest changing the entity name to be more unique? There are already a couple of mods that make electric-locomotive and installing two of them at once will break things. Maybe degraine-electric-locomotive. Then you could add compatibility with MUTC very easily by automatically adding all the locomotive names that start with degraine-electric-locomotive. This was the solution the author of Space Trains came up with, and I like it.

2 years ago

It took me longer than it should have to do all that, but it's finally done now. I tested it with your mod and there doesn't appear to be any issues, even with coupling or decoupling mid-charge, so you should be free to add support for my locomotives now! I've added the details of how to do that to the main page.

I took your advice and renamed everything, so the relevant entity is deg-electric-locomotive. It would probably be a good idea to add an internal fuel item that holds 500MJ, to go with the doubled energy consumption, as well.

New response