Page 1 of 1

[solved] game.write_file does not work at all

Posted: Wed May 02, 2018 7:00 pm
by mpk
hey everyone,
I'm trying to write data with game.write_file(path, data) however it does not work at all, neither in a mod nor when I run it via the ingame console with /c game.write_file('/home/user/text.txt', 'hello there')

when exactly does the game flush the written data? right after the call or does it cache all calls to write_data and waits for the game to close?
I'm on ubuntu, is there anything special I need to be aware of other than sufficient permissions?

Re: game.write_file does not work at all

Posted: Wed May 02, 2018 7:57 pm
by darkfrei
See Factorio\script-output

Re: game.write_file does not work at all

Posted: Wed May 02, 2018 8:06 pm
by keyboardhack
mpk wrote:When exactly does the game flush the written data? right after the call or does it cache all calls to write_data and waits for the game to close?
It should write the file immediately. If you are running this in multiplayer, try with the command /c game.write_file("text.txt", "hello there", false, 1)

Re: game.write_file does not work at all

Posted: Thu May 03, 2018 7:18 am
by mpk
darkfrei wrote:See Factorio\script-output
Yup there it is, that solves it. Factorio file writes seem to take this directory always as their root :roll:
This should be noted in the api wiki.