Here is my script:
Code: Select all
init python:
# This is set to the name of the character that is speaking, or
# None if no character is currently speaking.
speaking = erin
# This returns speaking if the character is speaking, and done if the
# character is not.
def while_speaking(erin, speak_d, done_d, st, at):
if speaking == erin:
return speak_d, .1
else:
return done_d, None
# Curried form of the above.
curried_while_speaking = renpy.curry(while_speaking)
# Displays speaking when the named character is speaking, and done otherwise.
def WhileSpeaking(erin, speaking_d, done_d=Null()):
return DynamicDisplayable(curried_while_speaking(erin, speaking_d, done_d))
# This callback maintains the speaking variable.
def speaker_callback(erin, event, **kwargs):
global speaking
if event == "show":
speaking = erin
elif event == "slow_done":
speaking = None
elif event == "end":
speaking = None
# Curried form of the same.
speaker = renpy.curry(speaker_callback)
# Create such a character.
define erin = Character("Erin", callback=speaker("erinhappy"))
# Composite things together to make a character with blinking eyes and
# lip-flap.
image erinhappy = LiveComposite(
(100, 780),
(0, 0), "erinbasehappy.png",
(0, 0), "erin eyes normal",
(0, 0), WhileSpeaking("erin", "erin mouth happy", "mouth3.png"),
)
image erin eyes normal:
"erineyes1.png"
choice:
5.5
choice:
4.5
choice:
3.5
# This randomizes the time between blinking.
"erineyes2.png"
0.1
"erineyes3.png"
0.1
"erineyes2.png"
0.1
repeat
image erin mouth happy:
"mouth1.png"
.1
"mouth2.png"
.1
"mouth3.png"
.1
repeat