Side panel with dynamic player portrait [solved]

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
kivik
Miko-Class Veteran
Posts: 786
Joined: Fri Jun 24, 2016 5:58 pm
Contact:

Side panel with dynamic player portrait [solved]

#1 Post by kivik » Fri Jun 24, 2016 6:16 pm

Hi there,

I'm just starting out with Ren'py and trying to build a game with a permanent side panel that includes player stats, as well as the player portrait.

As the player progresses through the game, they will acquire new appearances based on two or three variables, and I would like to show the appearance changes on the side panel automatically.

Ideally I want to be able to add a ConditionSwitch Image to the side panel, so that the character will automatically be updated based on the variable changes. However I'm not having success doing so (I may just be dense here).

I've managed to get it working by adding the image to the frame via a variable:

Code: Select all

add player_portrait
And if I update the variable manually but recombining the multiple variables after each, I can get it working:

Code: Select all

$ player_portrait = "player_[outfit]_[health]_[status].png"
I just wondered if there's an easier way that uses the ConditionSwitch?

Thank you in advance!
Last edited by kivik on Sat Jun 25, 2016 10:03 am, edited 1 time in total.

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

Re: Side panel with dynamic player portrait

#2 Post by chocoberrie » Fri Jun 24, 2016 7:03 pm

Hello! :)

I've figured out how to use ConditionSwitch to change the facial expressions of side image sprites, which is slightly different from what you're trying to do, but might still give you some insight into the coding you need. I wrote a tutorial here!

Basically, you need to define the new player stats and clothes with variables that can be easily recalled. In my code, I used numbers, so whenever I had the number defined later in the script, the images would appear. This means you won't have to write out every single possible combination of stats and clothes images! I hope this helps :D

kivik
Miko-Class Veteran
Posts: 786
Joined: Fri Jun 24, 2016 5:58 pm
Contact:

Re: Side panel with dynamic player portrait

#3 Post by kivik » Sat Jun 25, 2016 10:03 am

I had another look at the ConditionSwitch and realised that it would work on my player_portrait variable. I was under the misconception that it wouldn't return what I need for the image inside the window.

Now I can just change the variable to see different stats.

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], span4ev