[SOLVED] Display Side Image IF

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
PandoraSoul
Newbie
Posts: 5
Joined: Thu Aug 18, 2016 3:49 pm
Location: Alabama, USA
Contact:

[SOLVED] Display Side Image IF

#1 Post by PandoraSoul »

I am working on my first VN/sim and I'm pretty new to Ren'py and coding in general. I've searched various forums to try and find this answer, so I apologize if I overlooked it or didn't understand the solution I passed up was the right answer.

I'm trying to create a VN/sim with a "stress" stat, but don't want to have a stat bar. Instead, I'm wanting to have a character portrait (side image) that changes based on the percentage of the stress stat. I.E. when stress reaches 10% the character portrait changes. When it hits 20% it changes again. Ect. How would I code that in? I don't want to manually change it each time as I want random events to effect the stress stat, which automatically reflects on the character's side image.

Any help or pointers in the right direction would be very much appreciated!
Last edited by PandoraSoul on Thu Aug 18, 2016 10:08 pm, edited 1 time in total.

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: Display Side Image IF

#2 Post by trooper6 »

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

PandoraSoul
Newbie
Posts: 5
Joined: Thu Aug 18, 2016 3:49 pm
Location: Alabama, USA
Contact:

Re: Display Side Image IF

#3 Post by PandoraSoul »

trooper6 wrote:You'll want a ConditionSwitch
https://www.renpy.org/doc/html/displaya ... tionSwitch
Thank you for your response. Could you be a little more specific with how I could make that work? I didn't find any examples or tutorials when I was looking into Conditionswitches that were doing what I need to do. The closest thing I could find did pertain to changing side images, but it had to be triggered manually.

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: Display Side Image IF

#4 Post by trooper6 »

Well, I've never done it before, but I looked at the page I linked to, and the page on side images and made this tester, that works:

Code: Select all

define b = Character('Bill', color="#c8ffc8", image='bill')

default stress = 0

image side bill = ConditionSwitch(
    "stress == 9", "face5.png",
    "stress == 7", "face4.png",
    "stress == 5", "face3.png",
    "stress == 3", "face2.png",
    "True", "face1.png")
        
# The game starts here.

label start:
    
   b "Hello."
   $ stress=3
   b "Hello face 2"
   $ stress= 5
   b "Hello face 3"
   $ stress=7
   b "Hello face 4"
   $ stress=9
   b "Hello face 5"
 
return

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

PandoraSoul
Newbie
Posts: 5
Joined: Thu Aug 18, 2016 3:49 pm
Location: Alabama, USA
Contact:

Re: [SOLVED] Display Side Image IF

#5 Post by PandoraSoul »

Thank you! I guess I just didn't have a strong enough understanding of how the ConditionSwitch worked to realize that was my answer. :) I appreciate you taking the extra time to show me how to work it!

Post Reply

Who is online

Users browsing this forum: Sugar_and_rice