Externalize Lua
-
- Burner Inserter
- Posts: 6
- Joined: Sun Mar 06, 2016 9:45 pm
- Contact:
Externalize Lua
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.
Re: Externalize Lua
Why do you need an external c library? Just curious.
Re: Externalize Lua
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.
-
- Burner Inserter
- Posts: 6
- Joined: Sun Mar 06, 2016 9:45 pm
- Contact:
Re: Externalize Lua
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.
Re: Externalize Lua
It sounds interesting.
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
![Surprised :o](./images/smilies/icon_e_surprised.gif)
By the way, Rseding91, any comment on this post? viewtopic.php?f=120&t=23655
Re: Externalize Lua
package is not available for mods to use.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.
If you want to get ahold of me I'm almost always on Discord.
-
- Burner Inserter
- Posts: 6
- Joined: Sun Mar 06, 2016 9:45 pm
- Contact:
Re: Externalize Lua
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.