Page 1 of 1

[solved]remote reference available in on_load? (0.12.29)

Posted: Mon Mar 28, 2016 2:32 pm
by Impatient
hi!

i tested registering an interface to remote in the on_load handler. when calling upon that interface later in the on_tick handler it errors "interface unknown".

Code: Select all

function handleOnLoad()
	if not global.initializedOnLoad then
		initGlobals()
	else
	end
	-- migration needed?
	
	-- test registering remote interface in on_load -> does not work
	-- it seems the remote reference can not be used in the on_load handler
	remote.add_interface("DVM",
		{
			testOnLoad = remoteTestOnLoad
		}
	)
end
is the observation correct, that interface registration can not be done, when handling the on_load event?

thanks!

Re: remote reference available in on_load handler? (0.12.29)

Posted: Sun Apr 03, 2016 10:52 pm
by Impatient
some sort of answer:
The interfaces are not serialised. Therefore it is a good idea to put them into the global scope of the script. In that way they are run everytime the script file is loaded (no matter whether it is the first run or game being loaded).
from:
https://wiki.factorio.com/index.php?tit ... interfaces