(Solved)A side image with a changeable name and expressions?

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
Miss Nay
Newbie
Posts: 10
Joined: Mon Dec 29, 2014 2:10 am
Deviantart: JaiselArcher
Location: Los Angeles, CA
Contact:

(Solved)A side image with a changeable name and expressions?

#1 Post by Miss Nay » Fri Jul 01, 2016 4:42 am

Hello, I'm very new at coding in ren'py. I've been having trouble coding a side image for my MC that changes expressions, while also having her name be changeable. I can't wrap my head around how to make all of this work... :(
Last edited by Miss Nay on Sat Jul 02, 2016 9:40 pm, edited 1 time in total.

jw2pfd
Regular
Posts: 87
Joined: Tue Sep 18, 2012 9:55 pm
Location: DFW, TX, USA
Contact:

Re: A side image with a changeable name and expressions?

#2 Post by jw2pfd » Fri Jul 01, 2016 5:06 am

https://www.renpy.org/doc/html/side_image.html has a great example of how you could achieve something like this.

https://www.renpy.org/doc/html/dialogue.html - If you need a single character's name to be displayed differently, there is more than one option for something like this. I could help you out more if you either post some code or go into more specifics on what you're trying to achieve.

Miss Nay
Newbie
Posts: 10
Joined: Mon Dec 29, 2014 2:10 am
Deviantart: JaiselArcher
Location: Los Angeles, CA
Contact:

Re: A side image with a changeable name and expressions?

#3 Post by Miss Nay » Sat Jul 02, 2016 3:26 pm

Alright, so I have some lines of code that allow me to have my character be shown in the text box on the side while showing various expressions.
init:
image misha = "Misha Sprite.png"
$ m = Character("Misha", color = "#ffffff", show_side_image=ConditionSwitch
('misha==0', 'misha', xalign=0, yalign=1.0), window_left_padding=230)
Also, using these lines of coding for a player to able to change the MC's name works perfectly on their own.
label start:

"I've been thinking about changing my name."

# The phrase in the brackets is the text that the game will display to prompt
# the player to enter the name they've chosen.

$ player_name = renpy.input("What is your name, Magical Boy?")

$ player_name = player_name.strip()
# The .strip() instruction removes any extra spaces the player
# may have typed by accident.

# If the player can't be bothered to choose a name, then we
# choose a suitable one for them:
if player_name == "":
$ player_name="Shuji"

# And get a nostalgic sigh from Seasons of Sakura fans!

# Now the other characters in the game can greet the player.

e "Pleased to meet you, %(player_name)s!"


But what I'm having trouble with is getting the side image code, and a code that allows the player to change the MC's name to both work perfectly at the same time. Is there a group of coding that allows a player to choose their name and allow the MC's picture to show up at the side while that same side image is able to change expressions....? I hope all of this makes sense...

User avatar
chocoberrie
Veteran
Posts: 254
Joined: Wed Jun 19, 2013 10:34 pm
Projects: Marshmallow Days
Contact:

Re: A side image with a changeable name and expressions?

#4 Post by chocoberrie » Sat Jul 02, 2016 4:01 pm

Hello! I've got two tutorials about changing sprite facial expressions using ConditionSwitch and TransitionShowingSwitch:

Since you're using ConditionSwitch, you need to define a side image for misha==0 in the init block at the beginning of the script. That's probably why it's not showing a side image. Also, be careful of indentation! :)

For example:

Code: Select all

init:
    image misha = "Misha Sprite.png"
    image side misha_happy = "Misha_happy.png"
    $ m = Character("Misha", color = "#ffffff", show_side_image=ConditionSwitch('misha==0', 'misha_happy', xalign=0, yalign=1.0), window_left_padding=230)
So in your script, to show the side image, you would do this:

Code: Select all

label start:
    show misha
    $ misha = 0
    m "I'm happy!"
In the above code show misha will make the Misha sprite appear. $ misha = 0 will make the side image, "Misha_happy.png" appear.

The side image shows up because you have the same label defined in parentheses in the ConditionSwitch coding. misha_happy in the ConditionSwitch matches the misha_happy image defined in the side image, image side misha_happy.

You can use any side image with a facial expression of Misha that you want (I like putting the facial expression in the file name to make it easy to remember what expression the image shows).

I hope this helps! :)

jw2pfd
Regular
Posts: 87
Joined: Tue Sep 18, 2012 9:55 pm
Location: DFW, TX, USA
Contact:

Re: A side image with a changeable name and expressions?

#5 Post by jw2pfd » Sat Jul 02, 2016 5:54 pm

To make a character's name based on a value stored in a variable, you define a character like this:

Code: Select all

# A character that pulls its name from a variable.
define p = Character("player_name", dynamic=True)
Because the dynamic flag is set to True, the string is looked at as a variable name. So, whatever is stored in the variable player_name is displayed for the character's name. Also, when you post code, you want to use the code tag and not the quote tag so that it preserves the indentation.

Miss Nay
Newbie
Posts: 10
Joined: Mon Dec 29, 2014 2:10 am
Deviantart: JaiselArcher
Location: Los Angeles, CA
Contact:

Re: A side image with a changeable name and expressions?

#6 Post by Miss Nay » Sat Jul 02, 2016 9:33 pm

@chocoberrie and @jw2pfd, I used both of your codes and I managed to get everything to work! Thank you both so much! ^.^

Post Reply

Who is online

Users browsing this forum: DownAbbeyRoad, drKlauz, Google [Bot]