Reading a specific line in a txt file

Godot Version

4.2.1

Question

I have a settings menu and I want to save all of the settings data in one txt file and I was wondering if there is a way to read or write on a specific line.

Not directly, you need to iterate over the file and find the line, you should probably just use ConfigFile instead

I did see in the documentation that get line exits but I didn’t understand the description.

It returns the next line

Oh.
Ok

But couldn’t I just do a bunch of get_line() and I would be able to get to the correct line

Yes, that’s what I suggested, but it’s error prone, id suggest other methods

Ok thanks

1 Like