Page 1 of 1

Remote.interface in data.lua?

Posted: Mon Jun 16, 2014 6:37 am
by Rahjital
I'm currently trying to make a function accessible to other mods, so that if I update it, I don't have to update all the mods using the function as well. However, it seems the remote namespace is only accessible in control.lua, whereas I need it in data.lua. Is there any way to access the remote functions from data.lua? If not, is there any other way to share functions among mods?

Re: Remote.interface in data.lua?

Posted: Mon Jun 16, 2014 4:16 pm
by FreeER
Well, you could put that function in a separate 'helper' file and require it, but you'd still have to update that file for each mod...I'm not sure of any other way to do so. I'm not even sure if you can require files from other mods (ie, make a 'mod' with that file and have each of your other mods depend upon it and require the helper.lua file in them).

Re: Remote.interface in data.lua?

Posted: Mon Jun 16, 2014 4:41 pm
by Rahjital
Yeah, that's what I currently do, but I still have to update all the mods manually. It's not a big problem now, but if I release them, I'll have to redistribute all of them again, which is not nearly ideal.

I don't know of a way mods can load script files from each other. We can load files from the lualib folder in data/core, but I wasn't able to load from a lualib folder in my own mod. Maybe there's something I missing, but it doesn't seem to be possible at this moment. :(

Re: Remote.interface in data.lua?

Posted: Mon Jun 16, 2014 9:06 pm
by rk84
Well I think similar remote as ingame is not needed, because all mod loading happens in one environment => same global table for all mods.

Loading from lualib or factorio.exe folder does not work anymore? i guess your only option will be the separate helper mod as FreeEr said in last sentence. Except use helper mod save/require functions to global table and no helper require calls for other mods.

Re: Remote.interface in data.lua?

Posted: Mon Jun 16, 2014 9:56 pm
by Rahjital
You were indeed right! The shared global table makes everything so much simpler, all I had to do is define the function in one mod and then I was able to use it in all others. It never would have occured to me the loading phase is so different from the ingame phase, thanks, rk84!