Better way of string concatenation / joining?
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
-
renpycoder
- Newbie
- Posts: 7
- Joined: Fri Mar 09, 2018 12:58 am
- Contact:
Better way of string concatenation / joining?
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!
"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!
- Milkymalk
- Miko-Class Veteran
- Posts: 752
- Joined: Wed Nov 23, 2011 5:30 pm
- Completed: Don't Look (AGS game)
- Projects: KANPEKI! ★Perfect Play★
- Organization: Crappy White Wings
- Location: Germany
- Contact:
Re: Better way of string concatenation / joining?
You can use backslash \ as an escape character, so \' will work as a ' inside ' '.
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)
- Imperf3kt
- Lemma-Class Veteran
- Posts: 3636
- Joined: Mon Dec 14, 2015 5:05 am
- Location: Your monitor
- Contact:
Re: Better way of string concatenation / joining?
Another practise is simply to do things like this:
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.
Code: Select all
'"Hey, I can't do that!", said Johnny.'
I usually use a mixture, so I can't say which is 'better' than the other, but both ways will work.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Current project: GGD Mentor
Free Android GUI - Updated occasionally
Twitter
Imperf3kt Blackjack - a WIP blackjack game for Android made using Ren'Py
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Current project: GGD Mentor
Free Android GUI - Updated occasionally
Imperf3kt Blackjack - a WIP blackjack game for Android made using Ren'Py
- Ocelot
- Eileen-Class Veteran
- Posts: 1883
- Joined: Tue Aug 23, 2016 10:35 am
- Github: MiiNiPaa
- Discord: MiiNiPaa#4384
- Contact:
Re: Better way of string concatenation / joining?
And you might notice, that another single quote inside string breaks this statement. And, for some reason, RenPy does not supports triple-quoted strings.Imperf3kt wrote: ↑Sun Mar 11, 2018 1:13 amAnother practise is simply to do things like this:You'll notice I used ' to open and close the statement.Code: Select all
'"Hey, I can't do that!", said Johnny.'
I usually use a mixture, so I can't say which is 'better' than the other, but both ways will work.
I feel like line example in Creator-Defined Statements is exactly what is needed here:
https://www.renpy.org/doc/html/cds.html#example
< < insert Rick Cook quote here > >
- Imperf3kt
- Lemma-Class Veteran
- Posts: 3636
- Joined: Mon Dec 14, 2015 5:05 am
- Location: Your monitor
- Contact:
Re: Better way of string concatenation / joining?
Oh right, I totally missed that. In that case, yeah, use backslashes or atleast escape the apostriphied "can't"
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Current project: GGD Mentor
Free Android GUI - Updated occasionally
Twitter
Imperf3kt Blackjack - a WIP blackjack game for Android made using Ren'Py
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Current project: GGD Mentor
Free Android GUI - Updated occasionally
Imperf3kt Blackjack - a WIP blackjack game for Android made using Ren'Py
Who is online
Users browsing this forum: Bing [Bot], Google [Bot]