Skip to reading
GDScript Programming & Godot

4. Quotes, escapes and multiline text

Edition 0.86.4.1 HF1

0.86.4.1 Hotfix 1 edition. Earlier lessons and screenshots retain their original version context; revised references and supplements describe the newer behavior.

Download PDFView PDF page
Code example
func run() -> Array:
    var line_a: String = "It's locked."
    var line_b: String = 'The label says "Clockmaker".'
    var line_c: String = "He said \"come in\"."
    var two_lines: String = "First line\nSecond line"
    return [line_a, line_b, line_c, two_lines]
Source table from 4. Quotes, escapes and multiline text, page 12
In sourceResult
\nNew line
\tTab
\rCarriage return
\\Backslash
\"Double quote
\'Single quote

Single and double quotes both create String values. Triple quotes can hold multiline text. For an ID with spaces or punctuation, use a quoted string through a registry’s Get method:

Objects.Get("archive-door"). GDScript does not use PCA Script’s backtick record syntax.

Code example
func run() -> String:
    var inscription: String = """Turn the wheel.
Then ring the bell."""
    return inscription

A source line containing "$$score" is ordinary text. GUI wildcard replacement happens in the GUI’s text presentation, not automatically in every GDScript string.

Page 12 of 378Permalink
Go to page