Forum Mod Bakery Docs

External Process Communication

Please login to contribute to the conversation.
This was originally requested and debated in the Discord, but was advised to also be posted here.

Currently, the only "safe" method of external communication in a mod is to:
  • Create a mod framework, but do not compile it so it's still a folder
  • Require that framework in the mod you want to communicate with
  • Dynamically create a text file in the framework folder
  • In the mod, ReadFile(GetModPath("FrameworkName") .. "/TextFileName.txt")
This is clunky, easy to break, and most importantly is one way only.

My request is a system similar to TcpChannels in .NET. Unfortunately, I don't know C++ so I can't say the specifics, but I can say how it'd work with TcpChannels:
There would be a DLL with a common class and one function that is the function you communicate with.
The server (in this case HackSupport) creates a TcpChannel on a specified port.
There would be a function in the Lua similar to:
RegisterService("ServiceName", function(...)
    local args = {...}
    if #args > 0 and args[1] = "Hello" then
        return "World"
    end
    return ""
end)
This would call the equivalent of "RegisterWellKnownServiceType", with the type being the aforementioned DLL, the service name being the "ServiceName", and would register in HackSupport that any calls to the function on that server get passed through to the Lua function specified.

Now, providing there is a suitable alternative to TcpChannels in the languages used, this would open another wide avenue for modding. There would be limited security issues on the Mod Launcher side as it's only basic input output of variables, which can't access anything bad.
You would need to stress that 3rd Party Applications are run at the user's own risk. I personally would be happy to open source anything I did, but maybe a system where DT can have trusted/verified apps which they support.

Any questions or queries let me know and I'll try and answer.
Lucas plans on looking into this eventually but he's not sure when it might happen.