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.
-
Dizzydude
- Regular
- Posts: 58
- Joined: Mon May 26, 2014 8:40 pm
- Projects: 「To Be Announced」
- Location: U.S.A
-
Contact:
#1
Post
by Dizzydude » Wed May 20, 2015 2:46 pm
Hi, I'm trying to make a gender choice in my game using UI textbuttons, but it keeps returning as female. This is the code:
Code: Select all
$ ui.window()
$ ui.hbox()
$ ui.text ("What is your gender?")
$ ui.textbutton("Male", clicked=ui.returns("1"))
$ ui.textbutton("Female", clicked=ui.returns("2"))
$ ui.close()
$ gender = ui.interact(suppress_overlay=True)
$ p = renpy.input("What is your name?")
$ p = p.strip()
if p == "":
if gender == 1:
$ p = "Owen"
else:
$ p = "Ella"
if gender == 1:
$ p1 = "he"
$ p2 = "him"
$ p3 = "his"
$ p1c = "He"
$ p2c = "Him"
$ p3c = "His"
else:
$ p1 = "she"
$ p2 = "her"
$ p3 = "hers"
$ p1c = "She"
$ p2c = "Her"
$ p3c = "Hers"
For some reason, when I try the test:
Code: Select all
d "[p] playername test"
d "[p1] [p2] [p3] pronoun test"
d "[p1c] [p2c] [p3c] capital pronoun test"
It keeps returning as "Ella". Any help would be appreciated as to what I'm doing wrong.
EDIT: ..Yeah. Figured out the problem.
-
trooper6
- Lemma-Class Veteran
- Posts: 3712
- Joined: Sat Jul 09, 2011 10:33 pm
- Projects: A Close Shave
- Location: Medford, MA
-
Contact:
#2
Post
by trooper6 » Wed May 20, 2015 3:27 pm
Why are you using the older UI system rather than screen language? What advantage are you getting from the older system? I ask not as a challenge, but because I'm interested.
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
-
Dizzydude
- Regular
- Posts: 58
- Joined: Mon May 26, 2014 8:40 pm
- Projects: 「To Be Announced」
- Location: U.S.A
-
Contact:
#3
Post
by Dizzydude » Thu May 21, 2015 8:10 pm
Er.. new what now? I just use this one because I know about it. What's the new one? The hbox & vbox stuff? I'm just not sure how to use that.
I also wanted the gender choice to show up in the same place that the name choice showed up, and the UI stuff is in the textbox. Unless there's a way I can put renpy.input in the same place a vbox appears?
-
trooper6
- Lemma-Class Veteran
- Posts: 3712
- Joined: Sat Jul 09, 2011 10:33 pm
- Projects: A Close Shave
- Location: Medford, MA
-
Contact:
#4
Post
by trooper6 » Thu May 21, 2015 8:57 pm
Screen Language is the modern way of doing all of this...and has been for a while I'm pretty sure.
It is documented here:
http://renpy.org/doc/html/screens.html
This is my screen language translation of your code:
Code: Select all
screen start_choice():
frame:
vbox:
text "What is your gender?"
hbox:
textbutton "Male" action SetVariable("gender", "Male")
textbutton "Female" action SetVariable("gender", "Female")
text "Gender: [gender]"
text "-----"
text "What is your name?"
input
# The game starts here.
label start:
$gender = "Female"
$name = "Ella"
call screen start_choice()
$name = _return
$name = name.strip()
if name == "":
if gender == "Male":
$name = "Owen"
else:
$name = "Ella"
if gender == "Male":
$he = "he"
$him = "him"
$his = "his"
$He = "He"
$Him = "Him"
$His = "His"
else:
$he = "she"
$him = "her"
$his = "hers"
$He = "She"
$Him = "Her"
$His = "Hers"
e "[name] playername test"
e "[gender] gender test"
e "[he] [him] [his] pronoun test"
e "[He] [Him] [His] capital pronoun test"
I'm no expert in screen language, that is just what I came up with by looking through the documentation.
If you want the buttons and the questions not to show up in a frame, but in what looks like the say window, replace "frame" with "window"
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
Users browsing this forum: No registered users