game.write_file not appending

Place to post guides, observations, things related to modding that are not mods themselves.
Post Reply
mattie112
Burner Inserter
Burner Inserter
Posts: 7
Joined: Fri Jan 28, 2022 3:39 pm
Contact:

game.write_file not appending

Post by mattie112 »

https://lua-api.factorio.com/latest/Lua ... write_file

Code: Select all

write_file (filename, data, append, for_player) 
So I have this piece of code:

Code: Select all

local function log_message(msg)
    msg = game.tick .. " " .. msg
    game.write_file(baseFolder .. baseFile, "[FactorioChatBot]: " .. serpent.line(msg, { comment = false }, true))
end
And I expect my txt file to grow with 1 line each time this is executed. But: it's not. Only the last line is in the file. Why is the append not working?

robot256
Filter Inserter
Filter Inserter
Posts: 596
Joined: Sun Mar 17, 2019 1:52 am
Contact:

Re: game.write_file not appending

Post by robot256 »

Your "true" for the append argument is inside the parentheses for serpent.block.

mattie112
Burner Inserter
Burner Inserter
Posts: 7
Joined: Fri Jan 28, 2022 3:39 pm
Contact:

Re: game.write_file not appending

Post by mattie112 »

Guess it has been a long day... thanks!

Post Reply

Return to “Modding discussion”