When using game.tick_paused, I don't understand how to unpause the game after that.
The only delayed entry points that might work that I can find are GUI or key events. Is this true, or am I missing something important?
If not, I propose to add some kind of on_updated event, which works similar to on_tick, except it would only trigger on every 'draw' of the game instead of every update. This would serve 2 purposes:
1. It will keep functioning when the game is game.tick_paused. This way you can run code even when the game is paused withouth any user interaction.
2. Since it would only run every update instead of every tick, it could also help with the problem I was having here: viewtopic.php?f=65&t=65045
Maybe it should be split up into 2 events: on_updated which would work like on_tick but also when paused and on_redrawn which would only trigger when the screen is redrawn similar to described as above.
For the rest of this post, I'll explain my use case:
In factoriomaps, my goal is to generate day and night images that are exactly alike. It's important that these images are taken of the same tick, otherwise this would result in tears between the day and night version all over the map. In 0.16, I had to choose between restarting the game to do day and night separately, which can take a painful amount of time when dealing with a lot of mods, or taking the screenshots 1 tick apart.
In 0.16, my workflow was as follows:
tick 0: set daytime to day.
tick 1: hope the game has rendered, capture all day screenshots, set daytime to night.
tick 2: hope the game has rendered again and capture all night screenshots.
This left me with a day and night version of the capture that were 1 tick apart and thus had tears everywhere.
My hope is that I can use an event like on_updated to follow a similar workflow but while the game is paused.
on_updated: on_tick that works when paused
Re: on_updated: on_tick that works when paused
Having two on_tick events is probably never going to happen because it would double the performance cost of on_tick, which is probably already significant.
A much better solution is to add an on_paused_tick which just fires every tick when the game is paused, instead of the regular on_tick. Then, if you want to register an event that happens every tick whether or not the game is paused, you can use script.on_event({defines.events.on_tick, defines.events.on_paused_tick}, ... )
A much better solution is to add an on_paused_tick which just fires every tick when the game is paused, instead of the regular on_tick. Then, if you want to register an event that happens every tick whether or not the game is paused, you can use script.on_event({defines.events.on_tick, defines.events.on_paused_tick}, ... )
Re: on_updated: on_tick that works when paused
I'm pretty sure that game doesn't tick when paused.
What you are looking for is instant screenshot method that doesn't defer to after tick. Depending on how rendering is done it might be tad problematic.
Alternatively new parameter to screenshot method that passes time of day for screenshoot could help you with getting proper same tick screenshots.
What you are looking for is instant screenshot method that doesn't defer to after tick. Depending on how rendering is done it might be tad problematic.
Alternatively new parameter to screenshot method that passes time of day for screenshoot could help you with getting proper same tick screenshots.
Re: on_updated: on_tick that works when paused
Such an event still wouldn't work for what you want. The game has no direct connection between asking for a screenshot to be taken and when it happens. It can be in the same tick or it can be several later or never.
If you want to get ahold of me I'm almost always on Discord.
- Ranakastrasz
- Smart Inserter
- Posts: 2124
- Joined: Thu Jun 12, 2014 3:05 am
- Contact:
Re: on_updated: on_tick that works when paused
What happens if you set the gamespeed to zero?
Or something really low anyway.
Or something really low anyway.
My Mods:
Modular Armor Revamp - V16
Large Chests - V16
Agent Orange - V16
Flare - V16
Easy Refineries - V16
Modular Armor Revamp - V16
Large Chests - V16
Agent Orange - V16
Flare - V16
Easy Refineries - V16
Re: on_updated: on_tick that works when paused
You can simply run a loop that counts to a billion to distract the CPU until the screenshot finishes. What OP wants, and the devs won't give, is a way to wait for exactly the right amount of time.
Re: on_updated: on_tick that works when paused
No, that wouldnt do anything for me I think, since all the lua stuff is ran synchronously.
How about some delayed event/hook while the game is paused? This doesn't really address my main point in the OP, sorry for starting about multiple things at once.