on_ticks_played event

Things that we aren't going to implement
User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

on_ticks_played event

Post by bobingabout »

Long story short... my clock mod makes use of game.ticks_played to calculate total time played including in map editor while paused.
the this end, I have if game.ticks_played % 60 == 0 then in script.on_event(defines.events.on_tick, function()) to update the clock every time a second ticks.
This works fine as long as the game is running, but there's an issue... When in the editor, with the game paused, the clock display doesn't update. When you set time running again, it just jumps ahead 50 seconds, to 10 minutes, or however long you had the game paused in the editor.

Ideally, I need to put this inside an on_ticks_played event instead of on_tick event, but as far as I'm aware, it doesn't exists. So that's my request.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.
Rseding91
Factorio Staff
Factorio Staff
Posts: 14591
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: on_ticks_played event

Post by Rseding91 »

What about "on_paused_tick" - runs only when on_tick would normally not due to being paused through the map editor logic.

Note: the paused logic can run even outside of the editor so I don't want to associate the event name with the editor itself. It just happens that the editor is the main way most people access it.
If you want to get ahold of me I'm almost always on Discord.
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 3272
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: on_ticks_played event

Post by boskid »

Could we not have that? paused state is not something used heavily in game, and it could be abused by mods to change other parts of game state. When testing i depend on ability to pause time to investigate state (assuming mods do not catch on_selected_entity_changed event) and when mods would be able to run periodically when time is paused, it would make testing a lot worse - i would loose a "tick once" tool.
User avatar
raiguard
Factorio Staff
Factorio Staff
Posts: 614
Joined: Wed Dec 13, 2017 8:29 pm
Contact:

Re: on_ticks_played event

Post by raiguard »

I would also like this event, this means I could make Tapeline work while the tick is paused.
Don't forget, you're here forever.
User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5304
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: on_ticks_played event

Post by Klonan »

I also don't really like the idea of this event

When the tick is paused, I want all logic to be paused, I want a pristine and untouched environment
User avatar
Therenas
Factorio Staff
Factorio Staff
Posts: 261
Joined: Tue Dec 11, 2018 2:10 pm
Contact:

Re: on_ticks_played event

Post by Therenas »

But, not all logic is paused right? GUI events still work and can change the state of stuff no?
User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: on_ticks_played event

Post by bobingabout »

on_paused_tick works for me.

I do see the concern though, My personal use-case is just to update a "Time passed" display, related to a counter that continues to tick while the game is paused, but I can see how others could abuse it.

Then again, Other events like on_gui_click do still work while the game is paused, so in theory, whatever scripts could be run on a on_paused_tick can already be run while the game is paused manually by pressing a button on a GUI.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.
User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: on_ticks_played event

Post by bobingabout »

Is there a way to give it it's own bootstrap, Kinda like how on_load can't access game, only allow the on_paused_tick to access certain things, like the GUI, or other light things?

As for Boskid's concern, perhaps a console command that suspends the activation of on_paused_tick?
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.
User avatar
raiguard
Factorio Staff
Factorio Staff
Posts: 614
Joined: Wed Dec 13, 2017 8:29 pm
Contact:

Re: on_ticks_played event

Post by raiguard »

Bump. I have more GUI-related stuff that simply stops working when the tick is paused, which is quite annoying. on_tick_played would fix that!
Don't forget, you're here forever.
KeepResearchinSpoons
Long Handed Inserter
Long Handed Inserter
Posts: 77
Joined: Tue Dec 01, 2020 6:57 pm
Contact:

Re: on_ticks_played event

Post by KeepResearchinSpoons »

Bump.
I also somehow need this.
And I also want the ability to have the state to be perma-paused, not the way it works right now with either gui-pause (aaaa, reeeee) or tick_paused.

Well, as a workaround:
I "fixed" it as a side effect of having rcon poll the server ~60 times per sec.
When the game is "tick_paused" rcon events increment the ticks_played like a charm.
On a side note, they also increment game.tick even when player-paused lol, if tick_paused is unset. [not-a-bug]
Does it have to do with a complex scenario crap? Yes it does. A "dirty" workaround? Not so much, more of a pleasant side effect.
Does it fix the main issue? No. But... "Works for me" :>


Thread related.
In my opinion, we do not need such an even in the first place.
Reason: ticks_played is crazy volatile. It does not belong to a world/map. It belongs to a "server".

It is SO MUCH CHARMING to have it exposed ofc. Makes it easier to control the server by a whole lot.
And I would probably love to have the rcon scheduler work even without rcon. But then, how do I stop it in case anything goes haywire?
Afaik, the server may start a converted map midways (game.tick > 0), there is a game.speed, there is an editor pause, there is rcon
yet all of it are "external tools", not being run by the "scenario", or at least not meant to be run by an autonomous scenario.
Clock-wise, do you factor in the game.speed I wonder? Cuz ticks_played would prob really be the only feasible option afaics.
Do you factor in not-100% ups on getting laggy? Ah, here we go again, lets break the "4th wall" yet another time.

Like, when I "control" the server with these tools "from the outside", I expect the server-scenario part to be "sandboxed" inside all of this.
The server (headless) imo should NOT control the behavior of the debug tools that "debug" it. (unless it has a good and working api for that? With rpc stuff and all of it from the box? Nah prob not happening.)

What I do want however would be to pause the simulation updates over the entire specific surface.
short-overview-details
Post Reply

Return to “Won't implement”