Externalize Lua

Things that we aren't going to implement
Post Reply
bigjust12345
Burner Inserter
Burner Inserter
Posts: 6
Joined: Sun Mar 06, 2016 9:45 pm
Contact:

Externalize Lua

Post by bigjust12345 »

I’m currently trying to create a singleplayer mod that need to make use of an external c library. Currently this is impossible as lua has been statically linked into the executable. Right now if a dll is loaded it would result in an immediate crash as it could not be built against the correct lua environment. This can be solved either by creating a proxy dll or by moving lua into a dynamically linked dll.

User avatar
Mooncat
Smart Inserter
Smart Inserter
Posts: 1194
Joined: Wed May 18, 2016 4:55 pm
Contact:

Re: Externalize Lua

Post by Mooncat »

Why do you need an external c library? Just curious.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13235
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Externalize Lua

Post by Rseding91 »

We don't allow loading external libraries at all as it wouldn't be deterministic.
If you want to get ahold of me I'm almost always on Discord.

bigjust12345
Burner Inserter
Burner Inserter
Posts: 6
Joined: Sun Mar 06, 2016 9:45 pm
Contact:

Re: Externalize Lua

Post by bigjust12345 »

I do realize using external dll's would result in non-deterministic behavior. However I intend to use it solely in a single player environment so that determinism is not necessarily required. As for not allowing it, right now it is entirely possible to load an external c library. simply call package.loaders[3]("module name")() however as I said unless the module is built against factorio's copy of lua this will cause the game to instantly crash. To anwser mooncat's question I'm currently attempting to create an integration between rimworld and factorio, it's completely unbalanced and serves no useful purpose but I thought it would be neat. However to get it working requires that factorio be able to communicate externally. The easiest way would be use the zeromq lua binding.

User avatar
Mooncat
Smart Inserter
Smart Inserter
Posts: 1194
Joined: Wed May 18, 2016 4:55 pm
Contact:

Re: Externalize Lua

Post by Mooncat »

It sounds interesting. :o It will be amazing if you can do it. Unfortunately, I don't think Rseding91 will implement it because not so many people need it.

By the way, Rseding91, any comment on this post? viewtopic.php?f=120&t=23655

Rseding91
Factorio Staff
Factorio Staff
Posts: 13235
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Externalize Lua

Post by Rseding91 »

bigjust12345 wrote:I do realize using external dll's would result in non-deterministic behavior. However I intend to use it solely in a single player environment so that determinism is not necessarily required. As for not allowing it, right now it is entirely possible to load an external c library. simply call package.loaders[3]("module name")() however as I said unless the module is built against factorio's copy of lua this will cause the game to instantly crash. To anwser mooncat's question I'm currently attempting to create an integration between rimworld and factorio, it's completely unbalanced and serves no useful purpose but I thought it would be neat. However to get it working requires that factorio be able to communicate externally. The easiest way would be use the zeromq lua binding.
package is not available for mods to use.
If you want to get ahold of me I'm almost always on Discord.

bigjust12345
Burner Inserter
Burner Inserter
Posts: 6
Joined: Sun Mar 06, 2016 9:45 pm
Contact:

Re: Externalize Lua

Post by bigjust12345 »

I can assure you package can be accessed in 14.21 on windows (x64). I don't have a valid lua dll offhand to demonstrate the crash but here's me loading a dll. https://gyazo.com/58c6bd3a9e0effb92136855c02f2b445 had it been a proper dll it would have returned a function which could be called to initialize the dll.

Post Reply

Return to “Won't implement”