Possible to make http requests from mod?
Posted: Wed Aug 12, 2015 4:27 pm
I noticed that io and http modules aren't available.
www.factorio.com
https://forums.factorio.com/
Pretty sure this is intentional, so mods can not read your files, and send any passwords or documents off over the web.whatupdave wrote:I noticed that io and http modules aren't available.
it's more so that different clients can't desync.Afforess wrote:Pretty sure this is intentional, so mods can not read your files, and send any passwords or documents off over the web.whatupdave wrote:I noticed that io and http modules aren't available.
If you just want to get information out of Factorio, you can use game.write_file(path, data[, append]) to write it to a file, then write a program to watch that file for changes and post those to some website.Kalsius wrote:Sorry to necro a thread but it is directly relevant.
I am also wondering if an interface can be provided for basic GET/POST interactivity. I started on a mod which would allow multiple players to contribute to a goal which could be tracked on a website. Simple information on # resources sent to the 'project' would be the main aim with some level of additional security information included. I am guessing the devs are baking in relevant .dlls into the .exe to allow the running of lua and therefore have excluded (the security point is a very good one) certain aspects of lua ( and extensions such as luasocket ) for various reasons.
Very open to a discussion on this one.
Note that this API is very suboptimal and will actually write a file on every client in a server.prg wrote:If you just want to get information out of Factorio, you can use game.write_file(path, data[, append]) to write it to a file, then write a program to watch that file for changes and post those to some website.
This was plan B. I can keep the data collection local within the mod and then use some interface functions to then export the data. File write is a suboptimal solution but means that if we get some level of io/http interface I can just write a different interface and not have to mess with the core mod so much.prg wrote:.....
If you just want to get information out of Factorio, you can use game.write_file(path, data[, append]) to write it to a file, then write a program to watch that file for changes and post those to some website.
This is slight issue. Ideally i just want the server to create/manage an output log file which i can write a lightweight export program for which uses the web service specification i will define. One minor advantage is that anyone could write this piece of the solution given the appropriate specifcations.Zeblote wrote:Note that this API is very suboptimal and will actually write a file on every client in a server.
Forcing people to create symlinks to avoid garbage being written is not a good ideaprg wrote:Yeah I don't think there's currently an elegant solution for this. If someone doesn't want the file to be written, they can just symlink it to /dev/null or whatever the Windows equivalent is. Another possibility that would avoid intermediary files would be to write things to stdout, then pipe that to a program looking for lines matching a certain regex. No one else would notice since no one is running the game in a terminal and this doesn't go into the log file. But yes, this is kinda ugly of course.
Devs read at least the Modding interface requests forum, you might want to try there.
Yeah, no shit. Hence "I don't think there's currently an elegant solution for this." Besides no one is forced to create such a symlink. "If someone doesn't want the file to be written" would require people to care about it. If the log only contains "$player contributed $amount $resource" I guess it could grow to a couple kilobytes after a while, maybe even hundreds of kilobytes. A reasonable strategy for dealing with that would be to just ignore it.ratchetfreak wrote:Forcing people to create symlinks to avoid garbage being written is not a good idea
Nope. You must save/reload to change mods.devilwarriors wrote:mod manager is supposedly capable of loading mods in a multiplayer game without restarting
No, no change. I also don't think anything in that direction is planned.burisk wrote:I noticed that this is old thread. Is there any news about posibility to make http/https requests from server mod? Or at least support for SQL/NoSQL drivers (redis pubsub/sqlite/mysql) only on server of course.
For those using this function, game.write_file now has a for_player parameter where you can limit the file write to a single player or the server.Zeblote wrote:Note that this API is very suboptimal and will actually write a file on every client in a server.prg wrote:If you just want to get information out of Factorio, you can use game.write_file(path, data[, append]) to write it to a file, then write a program to watch that file for changes and post those to some website.