Actual Craft Time


Display actual craft times for assemblers, furnaces and rocket silo

Utilities
4 years ago
0.16 - 1.1
17.3K

g Optimization: Don't update multiple times per tick.

5 years ago

I don't use your mod but someone complained on the forums that it is really slow when you drag the slider. I measured up to 30.0ms used on a fresh empty map.

Your main function is tied directly into on_gui_value_changed, as this will be triggered several times per tick you do a lot of recalculation that is never used as the gui itself is only updated once pre tick. You should at the start of playerSlid check if the player already recieved an update in that tick, and if yes skip all further calulations.

Example:

if event.tick == global.whatever[event.player_index] then return else global.whatever[event.player_index] = event.tick.end

Though it would be even better if you only did the calculations every few ticks to further reduce the load, but that is less trivial to implement.

5 years ago

something to look into

New response