Furthermore, the documentation doesn't make clear that the specified event fires on every tick that is a multiple of n, instead of only on the nth tick; I had assumed the latter. I suggest something like "Register a handler to run on every tick that is a multiple of n.". It is also unclear whether, if you pass the array {2, 3} say, the handler is run once or twice on tick 6.Parameters
tick :: uint or array of uint: The nth-tick(s) to invoke the handler on. Passing nil will unregister all nth-tick handlers.
f :: function(NthTickEvent): The handler to run. Passing nil will unregister the handler for the provided ticks.
script.on_nth_tick crashes with nil; also documentation
script.on_nth_tick crashes with nil; also documentation
script.on_nth_tick(nil, nil) crashes, but the documentation says:
Re: script.on_nth_tick crashes with nil; also documentation
Thanks for the report however: no it doesn't. It gives a script error stating you gave invalid parameters (which you did).
You pass: script.on_nth_tick(nil) to unregister all nth-tick handlers or script.on_nth_tick(#, nil) to unregister that specific nth tick handler. Anything else is invalid.
You pass: script.on_nth_tick(nil) to unregister all nth-tick handlers or script.on_nth_tick(#, nil) to unregister that specific nth tick handler. Anything else is invalid.
If you want to get ahold of me I'm almost always on Discord.
Re: script.on_nth_tick crashes with nil; also documentation
You're right, I meant the script crashes not that the game crashes. (I forget that those are different things because the end result is I have to restart factorio either way.)
Thanks for letting me know about the correct usage. Could that also be documented? There is nothing in the documentation saying that f is an optional parameter or that it must be omitted if the first parameter is nil. The documentation reads as if on_nth_tick always takes two parameters.
Thanks for letting me know about the correct usage. Could that also be documented? There is nothing in the documentation saying that f is an optional parameter or that it must be omitted if the first parameter is nil. The documentation reads as if on_nth_tick always takes two parameters.