Page 1 of 1
Better way of string concatenation / joining?
Posted: Sat Mar 10, 2018 9:54 pm
by renpycoder
My visual novel involves third person point of view. I just noticed that in renpy, let's say you want something like this:
"Hey, I can't do that!", said Johnny.
^ This right here is hard to execute. If we do use ' ' around the " ", it can't be because you're using another single comma ( ' ) as an apostrophe.
Is there a better way of dealing with this?
Thanks in advance!
Re: Better way of string concatenation / joining?
Posted: Sat Mar 10, 2018 10:42 pm
by Milkymalk
You can use backslash \ as an escape character, so \' will work as a ' inside ' '.
Re: Better way of string concatenation / joining?
Posted: Sun Mar 11, 2018 1:13 am
by Imperf3kt
Another practise is simply to do things like this:
Code: Select all
'"Hey, I can't do that!", said Johnny.'
You'll notice I used ' to open and close the statement.
I usually use a mixture, so I can't say which is 'better' than the other, but both ways will work.
Re: Better way of string concatenation / joining?
Posted: Sun Mar 11, 2018 1:24 am
by Ocelot
Imperf3kt wrote: ↑Sun Mar 11, 2018 1:13 am
Another practise is simply to do things like this:
Code: Select all
'"Hey, I can't do that!", said Johnny.'
You'll notice I used ' to open and close the statement.
I usually use a mixture, so I can't say which is 'better' than the other, but both ways will work.
And you might notice, that another single quote inside string breaks this statement. And, for some reason, RenPy does not supports triple-quoted strings.
I feel like
line example in Creator-Defined Statements is exactly what is needed here:
https://www.renpy.org/doc/html/cds.html#example
Re: Better way of string concatenation / joining?
Posted: Sun Mar 11, 2018 3:35 am
by Imperf3kt
Oh right, I totally missed that. In that case, yeah, use backslashes or atleast escape the apostriphied "can't"