Page 1 of 1

on_nth_tick question

Posted: Sat Feb 08, 2020 7:58 pm
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?

Re: on_nth_tick question

Posted: Sat Feb 08, 2020 8:50 pm
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

Re: on_nth_tick question

Posted: Sat Feb 08, 2020 9:04 pm
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.