Page 1 of 1

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

Posted: Fri Jul 01, 2016 4:42 am
by Miss Nay
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... :(

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

Posted: Fri Jul 01, 2016 5:06 am
by jw2pfd
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.

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

Posted: Sat Jul 02, 2016 3:26 pm
by Miss Nay
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...

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

Posted: Sat Jul 02, 2016 4:01 pm
by chocoberrie
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! :)

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

Posted: Sat Jul 02, 2016 5:54 pm
by jw2pfd
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.

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

Posted: Sat Jul 02, 2016 9:33 pm
by Miss Nay
@chocoberrie and @jw2pfd, I used both of your codes and I managed to get everything to work! Thank you both so much! ^.^