4. Quotes, escapes and multiline text
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]| In source | Result |
|---|---|
| \n | New line |
| \t | Tab |
| \r | Carriage 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.
func run() -> String:
var inscription: String = """Turn the wheel.
Then ring the bell."""
return inscriptionA source line containing "$$score" is ordinary text. GUI wildcard replacement happens in the GUI’s text presentation, not automatically in every GDScript string.
