Is it possible to stick two words together?

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
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.
Post Reply
Message
Author
TheChatotMaestro
Regular
Posts: 91
Joined: Mon Jul 31, 2017 8:33 am
Deviantart: LedianWithACamera
Contact:

Is it possible to stick two words together?

#1 Post by TheChatotMaestro » Wed Apr 11, 2018 9:46 pm

I remember a function of renpy where it would take two words, like, defined in variables or something, and stick them together to make one word. Say you had a variable that was set to "song" and a variable that was set to "bird", it would put them together and come out with "songbird". I haven't been able to find it in any documentation, and I can't for the life of me remember what on earth it was called (or if it even actually exists), so googling doesn't do me much good. Does anyone know?

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3636
Joined: Mon Dec 14, 2015 5:05 am
Location: Your monitor
Contact:

Re: Is it possible to stick two words together?

#2 Post by Imperf3kt » Wed Apr 11, 2018 11:23 pm

Depends what you're using it for.
If you just want a player to name themselves, I guess this could work:

Code: Select all

default song = "player"
default bird = "one"

label start:
    e "Hello, [song][bird]."
I left out the character naming bit
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

User avatar
Lord Hisu
Regular
Posts: 58
Joined: Sun Feb 11, 2018 2:31 am
Contact:

Re: Is it possible to stick two words together?

#3 Post by Lord Hisu » Thu Apr 12, 2018 1:26 am

You can do it easily in Python:

Code: Select all

$ new_var = var1 + var2
var1 and var2 need to be strings, of course.

TheChatotMaestro
Regular
Posts: 91
Joined: Mon Jul 31, 2017 8:33 am
Deviantart: LedianWithACamera
Contact:

Re: Is it possible to stick two words together?

#4 Post by TheChatotMaestro » Thu Apr 12, 2018 9:46 pm

Thank you! Do you think this code would work?

Code: Select all

label checkprofilecalc:
    $ jumpconvo = convo + message
    jump [jumpconvo]
(Message is defined earlier when you use an item, and convo is defined when you go into the character interaction. When you use an item, it shows a screen that jumps to here, and puts the two together to make something like the label 'debuginteractionplaceholderitem' and then jump there, to show the character's proper reaction.)

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3636
Joined: Mon Dec 14, 2015 5:05 am
Location: Your monitor
Contact:

Re: Is it possible to stick two words together?

#5 Post by Imperf3kt » Fri Apr 13, 2018 12:11 am

Since they need to be strings, I would assume it should be:

Code: Select all

label checkprofilecalc:
    $ jumpconvo = "convo" + "message"
    jump [jumpconvo]
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

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Is it possible to stick two words together?

#6 Post by trooper6 » Fri Apr 13, 2018 12:16 am

I think you should also be able to use the expression keyword.

So:

Code: Select all

label checkprofilecalc:
    jump expression convo+message
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

Post Reply

Who is online

Users browsing this forum: Google [Bot]