[solved] Screen with choice of gender

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
Leviy
Newbie
Posts: 8
Joined: Sun Dec 23, 2018 5:09 am
Contact:

[solved] Screen with choice of gender

#1 Post by Leviy » Fri Aug 23, 2019 11:43 am

Hello.
I want to do choice of gender of character at the beginning of the game. I decided to realize that through screen in "screens.rpy". But how do I assign the result of choice to a specific variable in "script.rpy"?

screens.rpy.
screen choise_gender:
vbox align (0.5,0.5):
imagemap:
ground "scene/choise_gender.png"
hover "scene/choise_genderhover.png"
alpha True
hotspot (837, 501, 150, 77) action Return("Female")
hotspot (1032, 501, 151, 81) action Return("Male")

I tried to do that this way:

label start:
call screen choise_gender
if renpy.call_screen("Female"):
$ gender = f

But it didn't work. Error screen Female not known.
Last edited by Leviy on Fri Aug 30, 2019 1:48 pm, edited 1 time in total.

User avatar
IrinaLazareva
Veteran
Posts: 399
Joined: Wed Jun 08, 2016 1:49 pm
Projects: Legacy
Organization: SunShI
Location: St.Petersburg, Russia
Contact:

Re: Screen with choice of gender

#2 Post by IrinaLazareva » Fri Aug 23, 2019 12:04 pm

call screen choise_gender
if renpy.call_screen("Female"):
$ gender = f

Code: Select all

label start:
    call screen choise_gender
    if _return == "Female":
        $ gender = 'f'
https://www.renpy.org/doc/html/screen_a ... tml#Return

P.S. if desired, you can directly change the value of the variable with the appropriate action().

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: Screen with choice of gender

#3 Post by namastaii » Fri Aug 23, 2019 12:08 pm

You're trying to call a screen named 'female' and 'male' instead of assigning a variable.

Before the start label, include this:

Code: Select all

default gender = ""
If you'd like the default to be a specific gender, then put default gender = "female" etc

In your screen where your hotspots are, you'd do

Code: Select all

hotspot (837, 501, 150, 77) action SetVariable("gender", "female")
hotspot (1032, 501, 151, 81) action SetVariable("gender", "male")
If these hotspots also move to the next scene as soon as you click the gender, then you can have the hotspot return two actions

Code: Select all

hotspot (837, 501, 150, 77) action [SetVariable("gender", "female"), Jump("next_scene")]
hotspot (1032, 501, 151, 81) action [SetVariable("gender", "male"), Jump("next_scene")]

Code: Select all

label next_scene:
    if gender == "female":
        "You have chosen to be a girl"
    else:
        "You have chosen to be a boy"

Post Reply

Who is online

Users browsing this forum: Bing [Bot]