Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- init python:
- # This is set to the name of the character that is speaking, or
- # None if no character is currently speaking.
- speaking = None
- # If True, then all characters will be mute, i. e. their mouths
- # will be closed.
- mute = False
- # This is called by Ren'Py with the arguments passed to a say
- # statement.
- #
- # We use this callback to remember the value of the "mute"
- # argument (if any) that was passed to the last say statement.
- def say_arg_cb(who, *args, **kwargs):
- global mute
- # NB: Seems like the Ren'Py language uses unicode for keyword
- # argument names...
- mute = kwargs.get(u"mute")
- return args, kwargs
- # This makes Ren'Py actually call our callback.
- config.say_arguments_callback = say_arg_cb
- # This returns speaking if the character is speaking, and done if the
- # character is not.
- def while_speaking(name, speak_d, done_d, st, at):
- if speaking == name:
- 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(name, speaking_d, done_d=Null()):
- return DynamicDisplayable(curried_while_speaking(name, speaking_d, done_d))
- # This callback maintains the speaking variable.
- def speaker_callback(name, event, **kwargs):
- global speaking
- if event == "show":
- if mute:
- # If the say statement has a "truthy" mute attribute (e. g. mute=1),
- # then we do not make the character's mouth move: We keep it closed.
- speaking = None
- else:
- speaking = name
- elif event == "slow_done":
- speaking = None
- elif event == "end":
- speaking = None
- # Curried form of the same.
- speaker = renpy.curry(speaker_callback)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement