on_nth_tick question

Place to get help with not working mods / modding interface.
Anachrony
Fast Inserter
Fast Inserter
Posts: 143
Joined: Thu Sep 21, 2017 10:55 pm
Contact:

on_nth_tick question

Post by Anachrony »

I have been experimenting with on_nth_tick, and had a question. When I do a simple experiment in my control.lua to add an on_nth_tick handler it works. When I have another event handler call on_nth_tick(#,nil) to remove that handler, the tick handler is disabled as expected.

The issue is that the on_nth_tick hook I'd like to unregister comes from a different mod. When I call on_nth_tick with the tick number used by that mod, nothing happens and the handler keeps happening. Calling on_nth_tick with nil only seems to affect my own mod. This, coupled with the fact that script has a read only member called mod_name makes me think that each mod is using a different script variable. Is there some way to replace a different script's tick handler?
User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5411
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: on_nth_tick question

Post by Klonan »

Anachrony wrote: Sat Feb 08, 2020 7:58 pm Is there some way to replace a different script's tick handler?
Only if that mod makes a remote interface allowing you to do so.

Mod scripts are sandboxed, so they each have their own event listeners, data, and global
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: on_nth_tick question

Post by eradicator »

Klonan wrote: Sat Feb 08, 2020 8:50 pm Mod scripts are sandboxed, so they each have their own event listeners, data, and global
Slight expansion/correction: Mods are seperated only in control stage (i.e. "control.lua"). All other stages (settings.lua, data.lua, etc) use a single lua state that is shared between all mods.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Post Reply

Return to “Modding help”