Page 1 of 1

Put Lua C API in Export Table?

Posted: Tue May 31, 2016 1:02 pm
by Olipro
Assuming any developers read this - Would you consider exporting (into the export table of the PE) the Lua C API functions so that they can be invoked either with a simple GetProcAddress() call or if you include a generated LIB for dynamic linkage, even better. Obviously with the included PDB it's trivial to identify the functions to hook at runtime, but that's ugly and I'm hoping will be made unnecessary.

This would open up a lot of opportunity for interfacing the game with other programming languages and frameworks. My first thought was creating a hook-in to .NET for easy creation of a windows forms GUI for mod development/testing/messing around purposes. Although interfacing it with MRuby would be equally interesting, or integrating the in-game chat with Twitch/IRC.

Re: Put Lua C API in Export Table?

Posted: Wed Jun 01, 2016 8:22 am
by Moonheart08
Great idea! Integrateing ASM/C/C++/C#... Etc etc into the game would be really helpful.

Re: Put Lua C API in Export Table?

Posted: Wed Jun 01, 2016 2:30 pm
by Rseding91
That's not likely to ever happen. The potential for desyncs, crashes, save corruption, and just malicious mods in general is far too high for any benefits from exposing that portion of Lua in Factorio.

Re: Put Lua C API in Export Table?

Posted: Wed Jun 01, 2016 4:38 pm
by Olipro
Rseding91 wrote:That's not likely to ever happen. The potential for desyncs, crashes, save corruption, and just malicious mods in general is far too high for any benefits from exposing that portion of Lua in Factorio.
"Malicious Mods" is a bit of a stretch - someone willing to do that can simply make a mod that hooks the C API via runtime injection and then add their malicious code later on.

As for the desyncs, crashes, corruption etc. issue - Presumably you would have a folder for loading native mods and, if such a mod is found, indicate to the user a set of strong warnings about the possible risks.

Either way though, whilst you're entirely correct about such risks, they're there whether Factorio has 1st party exposure of the Lua C API or a third party shim.

Re: Put Lua C API in Export Table?

Posted: Thu Jun 02, 2016 9:29 am
by ratchetfreak
Olipro wrote:
Rseding91 wrote:That's not likely to ever happen. The potential for desyncs, crashes, save corruption, and just malicious mods in general is far too high for any benefits from exposing that portion of Lua in Factorio.
"Malicious Mods" is a bit of a stretch - someone willing to do that can simply make a mod that hooks the C API via runtime injection and then add their malicious code later on.

As for the desyncs, crashes, corruption etc. issue - Presumably you would have a folder for loading native mods and, if such a mod is found, indicate to the user a set of strong warnings about the possible risks.

Either way though, whilst you're entirely correct about such risks, they're there whether Factorio has 1st party exposure of the Lua C API or a third party shim.
The better option is to expand the lua api so that everything you would want to turn to the C-api for is achievable through the lua api

Re: Put Lua C API in Export Table?

Posted: Mon Jun 06, 2016 7:29 am
by Olipro
ratchetfreak wrote:
Olipro wrote:
Rseding91 wrote:That's not likely to ever happen. The potential for desyncs, crashes, save corruption, and just malicious mods in general is far too high for any benefits from exposing that portion of Lua in Factorio.
"Malicious Mods" is a bit of a stretch - someone willing to do that can simply make a mod that hooks the C API via runtime injection and then add their malicious code later on.

As for the desyncs, crashes, corruption etc. issue - Presumably you would have a folder for loading native mods and, if such a mod is found, indicate to the user a set of strong warnings about the possible risks.

Either way though, whilst you're entirely correct about such risks, they're there whether Factorio has 1st party exposure of the Lua C API or a third party shim.
The better option is to expand the lua api so that everything you would want to turn to the C-api for is achievable through the lua api
If what you are suggesting were achieveable, Lua itself would not need a C API.