+1 vote

I have a line of text in the RichTextLabel Bbcode field that reads:

[center][code]TM AND ©1989\nCAPCOM U.S.A, INC.\nLICENSED BY\nNINTENDO
OF AMERICA. INC.[/code][/center]

My issue is I can't get the line break/ new line to happen. As you can see I tried typing "\n" and have also tried "\r" which are common ways to do this in C-like languages. How can I get my line of text to appear in my app like the following?:

TM AND ©1989
CAPCOM U.S.A, INC.
LICENSED BY
NINTENDO OF AMERICA. INC.

If I need to use GDScript; I am new to GDScript, so example code is welcome. Thanks in advance for your assistance.

in Engine by (88 points)
recategorized by

1 Answer

+3 votes
Best answer

Hi again!

"\n" is the way to go:

get_node("RichTextLabel").set_bbcode("Hello\nWorld!")

Displays here (Godot 2.1.4) a text with a line feed.
When initializing the text with content from translation csv-files (no auto-init here I think)

I.e.:

get_node("gui/pnlHintHint/label").set_bbcode(tr("KEY_HINTHINT"))

I have a hex 0A in the csv-file for translation. (As done by open calc which I use as csv-editor).

When you want to set the linefeed directly in the godot editor (without gdscript) then just click the little icon right of the bbcode value field. A multiline editor will open where you can simply enter line feeds by pressing return.

by (3,252 points)
selected by

Thank you! You've been giving me an excellent impression of the Godot community!

The GUI based solution is what I need now - that worked.

Regarding the translation csv stuff. I'm not there yet. I will definitely favoritye your response though because I do intend to work with dynmaically loaded text in the future.

Thanks for including the GDScript solution. I suspect I will be needing that soon.

Best regards on the crunchy response. I hope that I may be able to help others as I begin stepping up. Cheers!

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 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 webmaster@godotengine.org with your username.