Line breaks in a file

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Ceilingdoor
:warning: Old Version Published before Godot 3 was released.

Hi!
If I write this string in the script editor: “1234\n1234”, the line will break, but if I write the same thing in a file, load it and print its contents, no line break occurs and the string is shown as is.
In the editor:
enter image description here

In a file:
enter image description here

How to make it break the line both in the editor and in a file?

:bust_in_silhouette: Reply From: Zylann

In a file, you write the actual line break, by pressing the Enter key. You should also ensure your editor writes the correct character (Windows style is \r\n, Mac style is \r and Unix \n, but it’s a matter of configuring your editor).

If you really need to write an explicit line break with “\n” for some reason, I guess you could do a string replace in GDScript to change “\\n” (note the escape character being escaped itself) into “\n”.

Many thanks! I’m making a dialogue system and store the dialogues in a file with special formatting and manually breaking the lines makes the text harder to navigate in. The second option is perfect in my case!

Ceilingdoor | 2017-01-25 15:21