I was surprised to learn that the in-game console commands are available over stdin while running a headless server. I haven't really found much official documentation on it other than some mentions in the changelog.
On Linux everything seems to work without any fuss. I can start a headless server from the terminal and type in commands. I can automate it from every language I've tried.
On Windows using the same command to start a server:
Code: Select all
factorio.exe --start-server-load-latest
However, when I run the node program:
Code: Select all
exe_loc="C:\\Program Files\\Factorio\\bin\\x64\\factorio.exe"
args=["--start-server-load-scenario","base/freeplay"]
f = require('child_process').spawn(exe_loc,args)
f.stdout.pipe(process.stdout)
Unfortunately, I can't seem to use node itself to write to Factorio's STDIN without it crashing. Adding the code below results in a crash
Code: Select all
setTimeout(()=>{
f.stdin.write('/h')
},3000)
According to some research the same seems to be true for C#.
However, I know FMTK successfully writes to Factorio's stdin using the same function calls that I tried in node. I've also heard of successes with Go and PowerShell.
So I guess I'd love some documentation on how Factorio opens it's STDIN on windows and ideally the conditions required to actually be able to communicate with it.