Page 1 of 1

Changing image based on who is speaking [SOLVED]

Posted: Wed Sep 23, 2015 12:15 am
by Jojobean
When a character is speaking, I want to display a different image than when they are not. Currently, I've been doing something like this:

Code: Select all

show queen grey
"The queen steps forward to greet you."
show queen
q "Hello child."
show queen grey
n "Hello, your majesty."
Eventually, I thought there must be an easier way to do this, especially when there are multiple characters in a scene. Is there a way to use a condition switch based on the character is speaking to change the displayed image? This would save me so much time!

Thanks so much!

Re: Changing image based on who is speaking

Posted: Wed Sep 23, 2015 12:43 am
by PyTom
It's available as _last_say_who. This is the unevaluated string, so you'll have:

Code: Select all

e "Hello, world." # _last_say_who == "e"
"Hello, Eileen." # _last_say_who == None
You should be able to use this in ConditionSwitch.

Re: Changing image based on who is speaking

Posted: Wed Sep 23, 2015 8:28 pm
by Jojobean
Thank you so much! That did exactly what I needed!!

Re: Changing image based on who is speaking [SOLVED]

Posted: Sun Nov 08, 2015 3:29 pm
by Jojobean
Here's the final code:

Code: Select all

define q = Character ('Queen Isabel')
Start by defining your character.

Code: Select all

 image queen =  ConditionSwitch(
            "_last_say_who == 'q'", "images/queen1.png",
            "not _last_say_who == 'q'", "images/queengrey.png")
Next use a condition switch with the variable _last_say_who . I guess Ren'py uses this to keep track of who is talking. Set it to equal the abbreviated version of the characters name.

Code: Select all

 q "hello there"
"chicken is delicious"
q "I hope it works!" 
The character should turn into the first image when she is speaking and the second image when she is not.

I hope this helps!