What?
An event that fires every tick like on_tick, but fires after the tick has completed.Why?
Some code is better to run before stuff happens while other code is better to run after.In one of my mods i paint the state of machines on top of them for easier reading of where you should direct your action.
With the current on_tick this code executes before the game completes the tick, which leads to inconsistencies on a tick level. So i would like to have the ability to execute code after a tick has completed but before a new tick begins.
Tick level precision is specifically important to me, as it relates to Tool assisted speedruns where it is easy control the game at this level of precision. However it could prove useful of other applications.
The discrepancy was noticed when switching from using:
Code: Select all
script.on_event(defines.events.on_tick, function(event)
game.tick_paused = true
end)
Code: Select all
script.on_event(defines.events.on_tick, function(event)
game.tick_paused = true
game.ticks_to_run = 1
end)
Example:
Below example is capture using my mod and a upcoming release of FTG. The circled number in the lower right corner of the assembling machine indicate the number of items available in the output slot. As seen in the above example, the tick has been completed and the machine has finalized the crafting of copper cable.Because the painting happened at the beginning of the tick, the output number is now incorrect at the end of the tick where the picture was captured.
Proposed implementation
Code: Select all
on_tick
It is fired once every tick after the game has completed the tick. Similar to on_tick. Since this event is fired every tick, its handler shouldn't include performance heavy code.
name :: Identifier of the event
tick :: Tick the event was generated.