Possible to make http requests from mod?
-
- Manual Inserter
- Posts: 2
- Joined: Wed Aug 12, 2015 4:24 pm
- Contact:
Possible to make http requests from mod?
I noticed that io and http modules aren't available.
-
- Smart Inserter
- Posts: 1847
- Joined: Sun Feb 23, 2014 3:37 pm
- Contact:
Re: Possible to make http requests from mod?
Am curious as to why you'd want that.
Re: Possible to make http requests from mod?
first obvious guess (for me): web service for sharing blueprints in-game?
Next guess (because people always make these, though I don't understand the appeal): inter-game chat/messaging system.
in any case, given the game's system of keeping peers entirely in sync, I don't see this being made available, certainly not outside of single-player games.
Next guess (because people always make these, though I don't understand the appeal): inter-game chat/messaging system.
in any case, given the game's system of keeping peers entirely in sync, I don't see this being made available, certainly not outside of single-player games.
My Mods:
Nixie Tubes - numeric displays for your circuit networks!
Logistic Combinators - use logistics values in circuit logic! -
Autowire - automate red/green wire connections
Nixie Tubes - numeric displays for your circuit networks!
Logistic Combinators - use logistics values in circuit logic! -
Autowire - automate red/green wire connections
-
- Manual Inserter
- Posts: 2
- Joined: Wed Aug 12, 2015 4:24 pm
- Contact:
Re: Possible to make http requests from mod?
First guess is spot on
Looking at ways of sharing blueprints and easy screenshot sharing.

Re: Possible to make http requests from mod?
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.
-
- Filter Inserter
- Posts: 952
- Joined: Sat May 23, 2015 12:10 pm
- Contact:
Re: Possible to make http requests from mod?
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.
Re: Possible to make http requests from mod?
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.
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.
Re: Possible to make http requests from mod?
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.
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!
Re: Possible to make http requests from mod?
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.
Re: Possible to make http requests from mod?
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.
I would prefer to go direct from the mod however as it would be cleaner and easier to deploy/manage without a secondary component.
Do devs monitor these threads?
Re: Possible to make http requests from mod?
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.
Devs read at least the Modding interface requests forum, you might want to try there.
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!
-
- Filter Inserter
- Posts: 952
- Joined: Sat May 23, 2015 12:10 pm
- Contact:
Re: Possible to make http requests from mod?
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.
Re: Possible to make http requests from mod?
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
I'm not saying this is a great way of doing things, just a way of making this work right now.
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!
-
- Filter Inserter
- Posts: 311
- Joined: Sat Jan 09, 2016 1:11 am
- Contact:
Re: Possible to make http requests from mod?
This mod manager is supposedly capable of loading mods in a multiplayer game without restarting -> https://forums.factorio.com/forum/vie ... 37&t=19454
couldn't the same thing they do be used, the mod create a text file, the server read it and delete it, then it create a new mod folder with the information it want to send back to the mod in-game and inject that mod into the running game.
it's a very horrible solution but you could make a blueprint manager that will refresh for everyone on the server when a new blueprint is added by someone, or something like that.
couldn't the same thing they do be used, the mod create a text file, the server read it and delete it, then it create a new mod folder with the information it want to send back to the mod in-game and inject that mod into the running game.
it's a very horrible solution but you could make a blueprint manager that will refresh for everyone on the server when a new blueprint is added by someone, or something like that.
Re: Possible to make http requests from mod?
Nope. You must save/reload to change mods.devilwarriors wrote:mod manager is supposedly capable of loading mods in a multiplayer game without restarting
Re: Possible to make http requests from mod?
I noticed that this is old thread. Is there any news about posibility to make http/https requests from server mod? I want to make web statistics and so other a lot of things but this stops me.. and no, I don't want to write to file and watch them.. That's perverse.
Or at least support for SQL/NoSQL drivers (redis pubsub/sqlite/mysql) only on server of course.

Re: Possible to make http requests from mod?
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.
-
- Inserter
- Posts: 29
- Joined: Sat May 07, 2016 3:57 pm
- Contact:
Re: Possible to make http requests from mod?
Found this via search engine:
Are there any updated/new plans to support SQL or HTTP?
Are there any updated/new plans to support SQL or HTTP?
Re: Possible to make http requests from mod?
No. But the headless server now supports console input, so you can write an external program to do it for you. See https://github.com/Bisa/factorio-init for an easy way to send console commands.
-
- Inserter
- Posts: 29
- Joined: Sat May 07, 2016 3:57 pm
- Contact:
Re: Possible to make http requests from mod?
Sorry for the delay: Thank you for this 
