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.
[solved] Screen with choice of gender
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.
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.
[solved] Screen with choice of gender
Last edited by Leviy on Fri Aug 30, 2019 1:48 pm, edited 1 time in total.
- 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
call screen choise_gender
if renpy.call_screen("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().
if
$ gender = f
Code: Select all
label start:
call screen choise_gender
if _return == "Female":
$ gender = 'f'P.S. if desired, you can directly change the value of the variable with the appropriate action().
- 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
You're trying to call a screen named 'female' and 'male' instead of assigning a variable.
Before the start label, include this:
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
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
Before the start label, include this:
Code: Select all
default gender = ""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")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"Who is online
Users browsing this forum: Bing [Bot]