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 = None
# This returns d if the character is speaking, and Null() if the
# character is not.
def while_speaking(name, d, st, at):
if speaking == name:
return d, .1
else:
return Null(), None
# Curried form of the above.
curried_while_speaking = renpy.curry(while_speaking)
# Displays d when the named character is speaking, and Null otherwise.
def WhileSpeaking(name, d):
return DynamicDisplayable(curried_while_speaking(name, d))
# This callback maintains the speaking variable.
def speaker_callback(name, event, **kwargs):
global speaking
if event == "show":
speaking = name
elif event == "slow_done":
speaking = None
elif event == "end":
speaking = None
# Curried form of the same.
speaker = renpy.curry(speaker_callback)
init:
# Create such a character.
$ girl = Character("Girl", callback=speaker("girl"))
# Composite things together to make a character with blinking eyes and
# lip-flap.
image girl = LiveComposite(
(359, 927),
(0, 0), "base.png",
(101, 50), anim.Filmstrip("eye.png", (152, 121), (3, 1), 1.0),
(170, 144), WhileSpeaking("girl", anim.Filmstrip("kuti.png", (62, 48), (3, 1), .1)),
)
# The game starts here.
label start:
scene black
show girl
"Not speaking."
girl "Now I'm speaking. Blah blah blah blah blah blah blah."
"Not speaking anymore."
girl "Now I'm speaking once again. Blah blah blah blah blah blah blah."