Train Trails


Trains create colorful glowing trails wherever they go. Very configurable

Tweaks
8 months ago
1.1
22.1K
Trains

i πŸ€” -> Suggestion: Performance Improvements

2 years ago

Hi,

i have noticed that the mod uses on_tick calculations which are a no-go for megabases. Since a megabase with many trains would look amazing with trails this is a very annoying limitation.

The mod Aircraft also adds smoke trails to the planes, but it uses a very different mechanic and adds a engine-handled smoke-definition to the energy source like

burner = {
      fuel_inventory_size = 2,
      smoke = { smokedef(-16, 60, 38), smokedef(16, 60, 38) }
}

with smokedef defined at: https://github.com/Stifling-Bossness/Aircraft/blob/413bc1372a8e5a8474db61c0ad10feda1b577b47/prototypes/entities.lua#L77

maybe you could check if some implementation strategies from aircraft might improve your mod

P.S. I would have played around with it myself but without a source-code repository it's to much of a hassle... sry

2 years ago

Hi Karoschel, thanks for that feedback!

Unfortunately I'm not sure that will work, since the trails are created using variables only available in control stage like the train color. I can mess around a bit and see if I can come up with something, but I'm not sure.

That being said I have spent a lot of time trying to reduce the script impact this mod has. If you haven't already, I'd encourage you to explore the different mod settings. By default the mod uses the "Pretty" performance mode setting, which means the code only runs every 2 ticks, but you can change that to every 4 ticks by choosing the "Efficient" mode instead.

The good thing is the script impact should only scale with number of trains, and even creating the trails on_tick ("Beautiful" performance mode) for ~350 trains should be less than 4ms, and just about or under 1ms on "Efficient" performance mode. I know that's still a lot, but there are some more potential optimizations planned for future releases I'm working on.

If you want to play around with the code yourself I do have it up on GitHub, it's just a bit hidden :P https://github.com/jingleheimer-schmidt/train-trails

p.s. If you have a megabase save handy, I'd be happy to use it for testing and benchmarking the mod!

New response