Electric Trains


The most advanced electric train mod out there! This mod adds balanced, UPS friendly and futuristic themed MAGLEV trains. This mod is meant to feel like an end-game extension to vanilla, and the new item recipes are balanced as such. These trains have a 20% increase in top speed, acceleration and capacity (mod configurable). There are more researches, items, sounds, recipes and logistical challenges and trade-offs to explore. Enjoy!

Content
5 months ago
1.1
3.43K
Transportation Logistics Trains

i [RELEASED] Support equipment grids

5 months ago
(updated 5 months ago)

Mods like Krastorio 2 outfits locomotives (and wagons!) with equipment grids. Some mods, like Equipment Grid Compatibility, help to bring that to other vehicles.

It would be nice if Electric Trains supports this feature automatically, by detecting if a locomotive or wagon supports a grid, and inheriting its size/supported equipment_categories. If this is outside the scope of this mod, I can instead suggest it over on Equipment Grid Compatibility's mod page.

5 months ago

Mods like Krastorio 2 outfits locomotives (and wagons!) with equipment grids. Some mods, like Equipment Grid Compatibility, help to bring that to other vehicles.

It would be nice if Electric Trains supports this feature automatically, by detecting if a locomotive or wagon supports a grid, and inheriting its size/supported equipment_categories. If this is outside the scope of this mod, I can instead suggest it over on Equipment Grid Compatibility's mod page.

Since I am not too familiar with the internals of the K2 mod I'm not too sure how I would go about it. It would be awesome if the compatibility mod catered for this one. It should be doable for them, since I have just finished renaming all items/entities in the code to be unique to this mod.

I think, post it on the compatibility mod page and let me know if they get back! I would be happy to cooperate to get this working for you :)

5 months ago
(updated 5 months ago)

Alright, I'll make a post on that other mod. What I'm doing locally, if you do want to do this yourself in a way that is mod-agnostic, is to do something like this:

local function inherit_grid(type_name, from_name, to_name)
    -- Do these entries even exist?
    if not data.raw[type_name][from_name] or not data.raw[type_name][to_name] then
        return
    end

    -- Skip inheriting if a grid is already defined earlier.
    if data.raw[type_name][to_name].equipment_grid then
        return
    end

    -- We also only want to inherit if there's something *to* inherit.
    local new_grid = data.raw[type_name][from_name].equipment_grid
    if not new_grid then
        return
    end

    -- We can now finally copy over to use the base equipment grid.
    data.raw[type_name][to_name].equipment_grid = new_grid
end

inherit_grid("locomotive", "locomotive", "electric-locomotive")
inherit_grid("cargo-wagon", "cargo-wagon", "electric-cargo-wagon")
inherit_grid("fluid-wagon", "fluid-wagon", "electric-fluid-wagon")

This will make the electric prototypes use whatever the base locomotive equipment grid uses, since it is crafted from a base locomotive. In K2's case, it will inherit "kr-locomotive-grid" or "kr-wagons-grid" which is just a string. All else that is needed is to mark Krastorio2 has an optional dependency to ensure that it loads first. Alternatively, maybe this property can be set at a later phase like data-final-fixes or data-updates so you don't need to do that with any other mod that adds locomotive equipment grids.

5 months ago

I can take a look at adding that code, that looks really good. Actually, better yet, do you wanna submit a pull request on the repo with that function implementing each of the wagon entities yourself? I don't have any easy access to an environment to test the rolling stock equipment grids, so if it works for you and the mods you use, it might be at least useful to someone else, without changing the experience for anyone that doesn't need it.

Would be totally awesome to have another contributor!

5 months ago

I would just chuck it at the end of data-updates.lua

5 months ago

Sounds good. I'll submit a PR after doing some more testing.

5 months ago

I look forward to reviewing it :))

5 months ago

Merged the PR. Thanks so much for your contribution, you'll go on the credits section of the info page and your changes will go live when 0.2.6 releases soon

5 months ago

Thank you for the prompt review and for catching that I missed the wagon locomotive. Happy to see the passionate progress here.

New response