Page 1 of 1

[Solved] Is there no way to make library for control.lua?

Posted: Wed Aug 03, 2016 4:35 pm
by Mooncat
Just to make sure, is there no way to make shared functions that can be used by control.lua from another mod?

Bob's library shows that it is possible to make library for data.lua, but I can't get it to work when making my library for control.lua. If I add require "the file from the library mod" in control.lua, it complains for no such file. I have tried
  • require "file-name"
  • require "mod-name/file-name"
  • require "__mod-name__/file-name"
but none of them works. if I don't add require, the function simply does not exist. :?

Edit:
The answer is: you can actually make library mod for control.lua.
The trick is to use remote.add_interface in your library mod, and use remote.call in the other mods.
See the API doc for more details.
Thanks DedlySpyder for the answer.

Re: Is there no way to make library for control.lua?

Posted: Wed Aug 03, 2016 4:49 pm
by DedlySpyder
You would have to use remote calls, as each mod is in its own sandbox, so they don't see each other besides using remote calls.

Bob's is different because the data stage of the game shares everything amongst the mods (I assume that also applies to his functions, though I've never looked too far into it)

Re: Is there no way to make library for control.lua?

Posted: Wed Aug 03, 2016 4:57 pm
by Mooncat
DedlySpyder wrote:You would have to use remote calls, as each mod is in its own sandbox, so they don't see each other besides using remote calls.

Bob's is different because the data stage of the game shares everything amongst the mods (I assume that also applies to his functions, though I've never looked too far into it)
I see. Totally forgot about the remote call. Thanks for reminding me. I will give it a try!

Re: Is there no way to make library for control.lua?

Posted: Wed Aug 03, 2016 6:30 pm
by Mooncat
Yes, remote call can do the trick. Thanks a lot.