[SOLVED] Mirror punchline problem
Posted: Fri Mar 12, 2021 2:20 pm
Hi,
first of all, sorry for my english ; I speak french...
In order to make a "Parrot function" that mirrors what the main character (player) is saying, I use a function that get the chain string of the last player punchline and then I use the .replace function.
But I encounter a problem and don't know how to solve it.
Here's my function:
#######################################
def MirrorPunchline(self):
P.Punchline = P.Punchline.replace("I am", "You are") #Punchline is a parameter in wich I save successfully the last chain-string said by the Player.
P.Punchline = P.Punchline.replace("I'm", "you're")
P.Punchline = P.Punchline.replace("me ", "you ")
Parrot.Punchline = P.Punchline
renpy.say(Parrot, "{}".format(Parrot.Punchline))
########################################
When I call this function: $ P.MirrorPunchline()
It works perfectly and the parrot repeats what the player says like this :
"""
Player : "I am very dumb."
Parrot : "You are very dumb."
""""
But, here comes the problem : how to improve this function when the player use sentences like this :
"I am proud of me as you are proud of you" <---- in this case, my function will replace "I am" by "You are" and "me" by "you" but the rest is tricky.
If I complete the code of the function to replace "You are" by "I am" and "you" by "me", it will return:
"I am proud of me as I am proud of me".
How to get around this ?
Thanks a lot
...
first of all, sorry for my english ; I speak french...
In order to make a "Parrot function" that mirrors what the main character (player) is saying, I use a function that get the chain string of the last player punchline and then I use the .replace function.
But I encounter a problem and don't know how to solve it.
Here's my function:
#######################################
def MirrorPunchline(self):
P.Punchline = P.Punchline.replace("I am", "You are") #Punchline is a parameter in wich I save successfully the last chain-string said by the Player.
P.Punchline = P.Punchline.replace("I'm", "you're")
P.Punchline = P.Punchline.replace("me ", "you ")
Parrot.Punchline = P.Punchline
renpy.say(Parrot, "{}".format(Parrot.Punchline))
########################################
When I call this function: $ P.MirrorPunchline()
It works perfectly and the parrot repeats what the player says like this :
"""
Player : "I am very dumb."
Parrot : "You are very dumb."
""""
But, here comes the problem : how to improve this function when the player use sentences like this :
"I am proud of me as you are proud of you" <---- in this case, my function will replace "I am" by "You are" and "me" by "you" but the rest is tricky.
If I complete the code of the function to replace "You are" by "I am" and "you" by "me", it will return:
"I am proud of me as I am proud of me".
How to get around this ?
Thanks a lot