Subscribing to on_tick for 1 tick - is it OK?

Place to get help with not working mods / modding interface.
Post Reply
User avatar
moon69
Fast Inserter
Fast Inserter
Posts: 181
Joined: Sun Sep 18, 2016 6:53 pm
Contact:

Subscribing to on_tick for 1 tick - is it OK?

Post by moon69 »

I want to do some light maintenence of my mod (using game object) once on every game load, so I do this by subscribing to on_tick and then unsubscribing in it's handler.

Is this the recommended method? Are there any pitfalls I need to look out for? Particularly wrt to multiplayer?

Cheers

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5153
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: Subscribing to on_tick for 1 tick - is it OK?

Post by Klonan »

You shouldn't really be doing things on game load, other than setting up metatable and things

What are you doing on load?

Subscribing to events on load is a very typical way to causing desyncs

User avatar
moon69
Fast Inserter
Fast Inserter
Posts: 181
Joined: Sun Sep 18, 2016 6:53 pm
Contact:

Re: Subscribing to on_tick for 1 tick - is it OK?

Post by moon69 »

Current intent is to close all mod guis that are saved open, remove custom selection-tool from hand, enable personal roboport and such things to give a clean start on resuming play.

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5153
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: Subscribing to on_tick for 1 tick - is it OK?

Post by Klonan »

moon69 wrote:
Fri May 01, 2020 1:57 pm
Current intent is to close all mod guis that are saved open, remove custom selection-tool from hand, enable personal roboport and such things to give a clean start on resuming play.
These things will definitely cause a desync

User avatar
moon69
Fast Inserter
Fast Inserter
Posts: 181
Joined: Sun Sep 18, 2016 6:53 pm
Contact:

Re: Subscribing to on_tick for 1 tick - is it OK?

Post by moon69 »

Thanks for advice.

Post Reply

Return to “Modding help”