How to show the correct image in a screen?[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
User avatar
facadepapergirl
Regular
Posts: 46
Joined: Thu Jan 31, 2013 7:27 pm
Projects: Pokemon: Final Evolution; Galactic Lust Crisis
Contact:

How to show the correct image in a screen?[Solved]

#1 Post by facadepapergirl »

I'm trying to do a sort of "character viewer" in my game, where one can see a picture based on their race/gender/whatever. For now, I only have an average female of each race, but for some reason, I can only get the boisin image, no matter the race flag. Below, is my code:

Code: Select all

screen stats_screen:
    hbox:
        frame:
            has vbox
            text "Level: [level]"
            text "Experience Points: [exp]"
            text "HP: [hp]"
            text "Intelligence: [smarts]"
            text "Power: [pwr]"
            text "Charisma: [cha]"
            text "Dexterity: [cha]"
            text "Toughness: [tou]"
            text "Hour: [hour]"
            text "[rlook]"
        frame:
            has vbox
            if boisin_race = True:
                image "Boisin_f.png"
            elif human_race = True:
                image "Human_f.png"
            elif winseen_race = True:
                image "Winseen_f.png"
            elif zinraf_race = True:
                image "Zinraf_f_front.png"
            
        
            textbutton "Return" action Return()
Since screen language is apparently different, I'm at a loss as to how I can fix this. Help?
Last edited by facadepapergirl on Wed Aug 28, 2013 7:09 pm, edited 1 time in total.

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

Re: How to show the correct image in a screen?

#2 Post by jw2pfd »

One thing I notice immediately in the following section of code:

Code: Select all

            if boisin_race = True:
                image "Boisin_f.png"
            elif human_race = True:
                image "Human_f.png"
            elif winseen_race = True:
                image "Winseen_f.png"
            elif zinraf_race = True:
                image "Zinraf_f_front.png"
Your conditionals are checking for equality with a single equal sign. They would need to have a double equal sign '=='. However, if you are only going to be assigning True and False values to those variables, then you can simply shorten the statement to:

Code: Select all

    if boisin_race:  #this is basically the same as saying 'if boisin_race == True:'
I guess you can use 'image' in screen statements? Personally, I use the 'add' statement. So, I would write the code like this for myself with the changes made:

Code: Select all

            if boisin_race:
                add "Boisin_f.png"
            elif human_race:
                add "Human_f.png"
            elif winseen_race:
                add "Winseen_f.png"
            elif zinraf_race:
                add "Zinraf_f_front.png"
If you are going to have a lot of potential portraits, then you may want to look at using an image with a condition switch.

User avatar
facadepapergirl
Regular
Posts: 46
Joined: Thu Jan 31, 2013 7:27 pm
Projects: Pokemon: Final Evolution; Galactic Lust Crisis
Contact:

Re: How to show the correct image in a screen?

#3 Post by facadepapergirl »

Any of the options you gave me removes the image entirely. I tried using add, then I tried image again, I tried adding two equal signs, and they all show, instead of a picture and return button in that frame, simply the return button. And I need to read more about the condition switch before I will try it; there isn't much in the documentation.

Anima
Veteran
Posts: 448
Joined: Wed Nov 18, 2009 11:17 am
Completed: Loren
Projects: PS2
Location: Germany
Contact:

Re: How to show the correct image in a screen?

#4 Post by Anima »

jw2pfd last code example is the/a correct way to do this.
Screenshots would help, as well as the dimensions of the pictures and screen.
Another problem might be that no variable is set to true, then nothing would be displayed of course.
Avatar created with this deviation by Crysa
Currently working on:
  • Winterwolves "Planet Stronghold 2" - RPG Framework: Phase III

User avatar
facadepapergirl
Regular
Posts: 46
Joined: Thu Jan 31, 2013 7:27 pm
Projects: Pokemon: Final Evolution; Galactic Lust Crisis
Contact:

Re: How to show the correct image in a screen? (H-game)

#5 Post by facadepapergirl »

Below, I have the stats screen for a female zinraf, and the variable viewer. The image shown is of a boisin, not a zinraf. The Boisin picture is 290x500, and the Zinraf picture is 277x500. In pixels, I believe. This is with the original code. I've put a spoiler as it contains a nude image and some of the flag names are not suitable for public view.
Screenshot.png
Screenshot2.png
This is with the two equal signs, the simple if whatever_race, and both with add instead of image:
Screenshot3.png
Any examples on how I might try out the condition switch? I do not understand it completely, and the documentation says for two things, but I have five races (the fifth image is not ready, so I have not added it.)

*EDIT* Nevermind, these aren't the spoiler tags I'm used to.

Anima
Veteran
Posts: 448
Joined: Wed Nov 18, 2009 11:17 am
Completed: Loren
Projects: PS2
Location: Germany
Contact:

Re: How to show the correct image in a screen?

#6 Post by Anima »

The code in the first post checks for the variable zinraf_race, the variable in the viewer is called zinref_race. Did you change the name or is this the problem?
Avatar created with this deviation by Crysa
Currently working on:
  • Winterwolves "Planet Stronghold 2" - RPG Framework: Phase III

User avatar
facadepapergirl
Regular
Posts: 46
Joined: Thu Jan 31, 2013 7:27 pm
Projects: Pokemon: Final Evolution; Galactic Lust Crisis
Contact:

Re: How to show the correct image in a screen?

#7 Post by facadepapergirl »

That is the problem. How very embarrassing. Thank you both very much for your assistance.

Post Reply

Who is online

Users browsing this forum: No registered users