The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

+2 votes

I'm making a logger script for my game, with a function that when is called, opens the log file, inserts the log text, and then closes it.

But I have run into a problem. Each time the new text overwrites the old one, so I would like to know how to append to the file instead.

in Engine by (57 points)

1 Answer

+6 votes
Best answer

Open the file with mode READ_WRITE, seek to the end with seek_end(), optionally insert a newline with store_string("\n") and write your log text.

by (1,530 points)
selected by

I was so close then! I did exactly that but just in WRITE mode.

if your using windows and your file is read in notepad like me, ("\n") will not work, so you should use ("\r"). That much is what I know, regarding seek_end(), it doesn't seem to go to the end of my file. It just stays in the beginning. I'll update this when I got the chance to understand why.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.