0 votes

I'm making a game currently where I want there to be apostrophes within the dialogue. All of the dialogue is inside of a list, and for some reason simply printing the dialogue with the apostrophe works as shown in this example:

print("example: the girl\'s house")

But for some reason when I put that string in the list, I'm given an error saying "Parse Error: Invalid escape sequence"

dialogue = ["example: the girl\'s house"]

I don't understand why this is happening, and I'd really like to have apostrophes in my dialogue, so if you know why this happening or how to fix this, I'd really appreciate the help.

in Engine by (33 points)

1 Answer

+2 votes
Best answer
func _ready():
var dialogue = ["example: the girl\'s house"]

Works perfectly. A note the "girl\'s" part can also be just "girl's" with no difference.
The \ symbol is only needed with " in my tests, as in:

var dialogue = ["\"example: the girl's house\""]

will print : "example: the girl's house" with the " apostrophes.

It is unclear what that error is but maybe you should convert to string just in case.

print( str(dialogue[0])) #see if this works for you
by (1,490 points)
selected by

Oh my gosh thank you so much for this answer. I realized because of your answer that the reason I couldn't escape was because I was using an apostrophe and not quotes, and so instead of wasting my time on that, I was able to figure out that the root of the cause was that the font I was using didn't have an apostrophe, so now I'm using a different font and it's working. Thank you again for your answer.

Thank you for clearing up what the problem was, as a person who uses a lot of custom fonts now I know what that error means; I was bound to run into the same problem sooner or later.

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 Frequently asked questions and 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 [email protected] with your username.