How to go to a new line in a String like \n in some languages?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By rz

So I have a Popup menu and I have a label in it, I want the label to display stats like:

Wins: 5
Losses: 8
Ties: 3

Where each stat is on a new line, in a single label. Some languages such as C has a feature where you add in \n in string to go to a new line. How do I do this in GDScript? I’m editing the text from a script.

:bust_in_silhouette: Reply From: shenqi

当然是用\n就可以了。。。。。

Mark this answer as Funny

USBashka | 2022-07-13 16:16

:bust_in_silhouette: Reply From: USBashka

Em. Well, it’s actually \n

Or you can use triple quotes to make multiline string in script like that:

$Label.text = """Wins: 5
Losses: 8
Ties: 3"""
:bust_in_silhouette: Reply From: 882039

\n is working fine for me. Try get_node(your label).set_text("LINE1\nLINE2")

Edit: someone was 13 seconds faster…

:bust_in_silhouette: Reply From: PAndras

I’ve just had a similar problem. I’ve written to a txt file (as a test), and checked the result from the standard windows txt-editor. The newline character is there, just the txt-editor did not want to show me, and wrote the whole thing in one line.