Search code examples
godotgdscript

How to edit a previous line of a Label with a script in Godot


I need to add something to a label that's up on a line above an existing line with a script, how would I do that?


Solution

  • The question is a bit vague but as I understand it you want to add a line of text above the existing text in a label.

    Simply add "\n" where you want your text to have a line break and have the text after the line break be the original text of the label. For example:

    var label = get_node("node_path")
    label.text = "YOUR NEW TEXT\n" + label.text