Disco Science


Makes science labs light up with the colours of the science packs they are consuming.

Tweaks
3 years ago
0.17 - 1.1
167K

i Performance

4 years ago

Performance seems to drop dramatically of you go bananas with the amount of labs on a map (active or not). Is this known? Anything that can be done about it? Maybe a simpler disco pattern? I wouldn't mind one where there is no pattern change at all, just a glow depeding on what science packs are currently being used.

4 years ago

I've put a fair bit of effort into performance, and my experience was that calculating the colours for each lab is relatively insignificant compared to just iterating through all of them. The updates are strided, meaning not every lab is updated every frame, and I've played around with the iteration approach to get it as fast as possible. I'd like to be able to only update labs when they're on screen, but unfortunately Factorio's synchronisation rules mean that everything needs to be kept in sync for all players.

Still, I'm open to any improvements if you're able to find optimisations that I missed!

4 years ago

You clearly looked into this with more knowledge than i could ever provide, but i wonder if at least when they aren't running, do they still eat up more resources?

4 years ago

Unfortunately they do still eat up resources when not running. ☹️

I could possibly prevent this, but I feel like it's not really worth the effort when the worst case (labs running) is still a really common one. I think if you're at the point where the mod is slowing down your game, you are better off disabling it. Otherwise you'll just curse my mod whenever your labs are running. 😃

4 years ago

If it CAN be done, adding it would be nice :D Also is there nothing in regards to the actual way it iterates through labs that can help performance on bigger lab setups? I'm curious, what is the exact process you made to iterate through labs to get them to behave this way?

4 years ago

Here's the loop: https://github.com/danielbrauer/DiscoScience/blob/550f39fcaa861335936ecec89c48f176ae2e1f16/src/core/labColoring.lua#L97

If you want, you could try changing the "stride" value in the file to something higher. Right now it's at 6, which means every lab gets updated every six frames. Higher numbers mean fewer labs are updated per frame, but it means animation will lag a bit.

(If you're not familiar with editing mods, you can just unzip the mod in Factorio's mods folder and it will prefer the unzipped version)

New response