Remote.interface in data.lua?

Place to get help with not working mods / modding interface.
Post Reply
Rahjital
Filter Inserter
Filter Inserter
Posts: 435
Joined: Thu May 29, 2014 10:44 am
Contact:

Remote.interface in data.lua?

Post 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?

User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: Remote.interface in data.lua?

Post 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).

Rahjital
Filter Inserter
Filter Inserter
Posts: 435
Joined: Thu May 29, 2014 10:44 am
Contact:

Re: Remote.interface in data.lua?

Post 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. :(

User avatar
rk84
Filter Inserter
Filter Inserter
Posts: 556
Joined: Wed Feb 13, 2013 9:15 am
Contact:

Re: Remote.interface in data.lua?

Post 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.

Rahjital
Filter Inserter
Filter Inserter
Posts: 435
Joined: Thu May 29, 2014 10:44 am
Contact:

Re: Remote.interface in data.lua?

Post 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!

Post Reply

Return to “Modding help”