r_sami wrote:Lines starting with $ are Python and not Ren'py
Is it...is it not the other way around? Have I been wrong this whole time?
Nope. $ is Python, without is Renpy.
r_sami wrote:
is pythonic, and
is renpyic (for this example, at least), right?
Yep, but I prefer the newer .format code over the older % code for string interpolation whenever I have the choice.
So in a general sense there are lots of ways to deal with switching pronouns. If I were doing this just with Renpy, and not dealing with the random phrase element, let's say dealing with the pronouns of the main character? I'd do something like this:
Code: Select all
default he = "he"
default him = "him"
default his = "his"
default He = "He"
default Him = "Him"
default His = "His"
# The game starts here.
label start:
"Game starts"
menu:
"Is the main character male, female, or gender neutral?"
"Male":
pass
"Female":
$ he = "she"
$ him = "her"
$ his = "hers"
$ He = "She"
$ Him = "Her"
$ His = "Hers"
"Neutral":
$ he = "ze"
$ him = "hir"
$ his = "hir"
$ He = "Ze"
$ Him = "Hir"
$ His = "Hir"
"Thank you."
"When the story starts, Alex is just waking up. [He] rubs [his] eyes and looks around [him]self. What will [he] do today?"
return
I think sort sort of thing is clever. But that isn't what the OP asked for. The OP wants a random phrase chosen of three and wants pronoun interpolation.
You can do it like this:
Code: Select all
default pronouns = {"male":["he", "him", "his"], "female": ["she", "her", "hers"], "neutral": ["ze", "hir", "hirs"]} #your dictionary of pronouns
default gender = "female" #what your default gender is
# The game starts here.
label start:
"Game starts"
$ saying = renpy.random.choice(["{p[0]} takes {p[1]} business elsewhere".format(p=pronouns[gender]),"unable to find the deal {p[0]} sought, {p[0]} leaves the store".format(p=pronouns[gender]),"{p[1]} interest wanes and {p[0]} leaves".format(p=pronouns[gender])]) #This is using the .format code for interpolation
"With Female"
"[saying]"
"This works"
"With male"
$gender = "male"
"[saying]"
"This won't work, it will still use female pronouns!"
return
So the code I posted works, but it will always use the first set of pronouns you give it even if you change the gender later, because you only set the saying phrase once. So I recommend creating a function that returns a newly formatted random phrase every time you call it like so:
Code: Select all
default pronouns = {"male":["he", "him", "his"], "female": ["she", "her", "hers"], "neutral": ["ze", "hir", "hirs"]}
default gender = "female"
init python:
def leave(g):
global gender
gender = g
return renpy.random.choice(["{p[0]} takes {p[1]} business elsewhere".format(p=pronouns[gender]),"unable to find the deal {p[0]} sought, {p[0]} leaves the store".format(p=pronouns[gender]),"{p[1]} interest wanes and {p[0]} leaves".format(p=pronouns[gender])])
# The game starts here.
label start:
"Game starts"
"With Female"
$saying = leave("female")
"[saying]"
"With male"
$saying = leave("male")
"[saying]"
"With plural"
$saying = leave("plural")
"[saying]"
return
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