Electric Tiles


Adds conductive floor tiles that transmit power to adjacent tiles (including diagonals) and any structure on top of them, just place a power source or electric pole on top and enjoy the extra space!

Content
2 months ago
2.0
2.07K
Power

g Cool mod, performance concerns?

3 months ago

Cool mod idea. I never concrete my factories, this might change that.

I was reading through your code, specifically:
script.on_event(defines.events.on_tick, function(data) on_tick_fun(data.tick) end)

That function looks a bit heavy? Is it required to run an operation every tick and not just on events for a mod like this?

3 months ago

The same I thought may friend, however there is a special reason why that event must be taken on considerations: timers.

What on_tick does is just count down an update timer, nothing else. Once the timer reaches 0, the main process of the mod happens.

Plus, the timer only starts once you or a robot build/remove a tile, AND it can be restarted (without activating the main process) by just building more tiles faster than the timer goes down.

Once you build, you have 1second by default to build or remove tiles, and once that second of inactivity happens, the procces fires.

3 months ago

This optimisation was implemented in 1.1.0!

3 months ago

👍

3 months ago

So, replacing the entire factory floor seems to be a bad idea.

Every few seconds (I assume when the aforementioned timer reaches 0), the tick which processes/recalculates the electrical grid takes more than 7000ms.

Here's a screenshot of the debug timings after my bots placed 7k of 10k electric tiles: https://imgur.com/a/RprT33D

3 months ago
(updated 3 months ago)

Yeah, actually is something like that.

Cause of the chunk-processing, once a tile is placed/removed, the entire chunk where the tile is/was will be recalculated.

If you manage to place TOO MUCH tiles before the timer goes down, then it will process all of those chunks, with no exceptions, even the ones where only 1 was placed/removed.

However, there is a counter measure for this, a forcing timer, wich cannot be reset, and stops the timer from resetting for long times.

The forcing timer is x10 the delay time of the normal timer.

So, my best guess is that you manage to place all those tiles inside the time frame of the forcing timer (10 seconds in normal mod settings), and cause of that, all the lag.

The forcing timer allows to keep placing tiles for long times (even when its pourpose is the contrary) because it makes the mod process the already placed tiles.

Think about it like this: You wanna keep placing tiles? Alr, just let me work with the already placed ones, so i dont have to do it later.

It is a one time trade also, once you put the tiles, the mod processes them, and then nothing else happens.

Its the best performance saver method that i could think of ...

3 months ago
(updated 3 months ago)

The only problem is building TOO much, TOO fast xd

3 months ago

Yeah, I figured. I've since started to place at most 2-3k tiles, the huge spikes went away (some still take 100ms, but only if the bots needed to detour to a roboport for charging). Manually placing electric tiles did not show this behaviour, which is nice.

Still, this came a bit of a surprise. Maybe add a small warning to the mod description? Something along "Beware: Due to technical limitations, placing a huge number of tiles with a blueprint WILL cause large UPS spikes every few seconds. Best limit yourself to a few thousand tiles or place the tiles manually".

3 months ago

yeah, I'll consider adding it in the description.

New response