Need Help for Gender Customization!

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
Tritonials
Newbie
Posts: 16
Joined: Fri Sep 21, 2018 6:32 pm
Completed: None. Still learning how to code.
Contact:

Need Help for Gender Customization!

#1 Post by Tritonials »

So i'm making this game, which players can pick genders, and the avatar or sprite will show the specific gender they chose.

Code: Select all

"Pick which gender":
      "Male":
             $ male = True

      "Woman":
             pass 
                     
if male == True:
show male at left

else:
show woman at right 
But if i were to show the player's character multiple times I would have to copy paste the else/if multiple times. Is there any other way to do this? Thanks! :D

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Need Help for Gender Customization!

#2 Post by Remix »

Code: Select all

default pc_gender = "male"
image pc_sprite = "images/[pc_gender].png"

label start:
    show pc_sprite # shows "images/male.png"
    "..."
    $ pc_gender = "female" # changes to now show "images/female.png"
    "..."
Frameworks & Scriptlets:

User avatar
Tritonials
Newbie
Posts: 16
Joined: Fri Sep 21, 2018 6:32 pm
Completed: None. Still learning how to code.
Contact:

Re: Need Help for Gender Customization!

#3 Post by Tritonials »

Thank you very much! I'll try it when i got home!

User avatar
Bum_McFluff
Regular
Posts: 45
Joined: Sat Aug 18, 2018 8:15 pm
Contact:

Re: Need Help for Gender Customization!

#4 Post by Bum_McFluff »

Remix wrote: Mon Oct 29, 2018 8:10 am

Code: Select all

default pc_gender = "male"
image pc_sprite = "images/[pc_gender].png"

label start:
    show pc_sprite # shows "images/male.png"
    "..."
    $ pc_gender = "female" # changes to now show "images/female.png"
    "..."
This doesn't work for me, because when I add $ pc_gender = "female" # changes to now show "images/female.png" then add show x at left it doesn't change anything, I still see the male image.

x is the shorthand name of my character

It doesn't show how to assign the female image. I assign the default as male, but no mention of the alternative. How do I write default = male and not default = female? Do I have to add something like default x pc_gender = "male"?
What, spy on our spy as he searches for their spy? Why not, sounds rather like fun.

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Need Help for Gender Customization!

#5 Post by Remix »

When you write ' show something at left ' you show an image, not a character...
Frameworks & Scriptlets:

User avatar
Bum_McFluff
Regular
Posts: 45
Joined: Sat Aug 18, 2018 8:15 pm
Contact:

Re: Need Help for Gender Customization!

#6 Post by Bum_McFluff »

Bum_McFluff wrote: Sat Feb 22, 2020 6:50 pm
Remix wrote: Mon Oct 29, 2018 8:10 am

Code: Select all

default pc_gender = "male"
image pc_sprite = "images/[pc_gender].png"

label start:
    show pc_sprite # shows "images/male.png"
    "..."
    $ pc_gender = "female" # changes to now show "images/female.png"
    "..."
This doesn't work for me, because when I add $ pc_gender = "female" # changes to now show "images/female.png" then add show pc_sprite at left it doesn't change anything, I still see the male image.

It doesn't show how to assign the female image. I assign the default as male, but no mention of the alternative. How do I write default = male and not default = female?
Doesn't it require something like

Code: Select all

    show pc_sprite # shows "images/male.png"
    if pc_gender = female then "images/female.png"
What, spy on our spy as he searches for their spy? Why not, sounds rather like fun.

Post Reply

Who is online

Users browsing this forum: No registered users