- Character callbacks: https://renpy.org/doc/html/character_callbacks.html
- _last_say_who is an internal variable Ren'py maintains. This basically just creates two extra variables to track when the speaker changes. I added underscores to _speaker_changed and _last_last_say_who for fun. (Well, really because you probably shouldn't be changing them manually.)
- There are definitely other ways to do this; I'm posting something super simple and barebones that will prob work for most cases.
Code: Select all
init 2 python: def speaker_change_callback(event, interact=True, **kwargs): global _speaker_changed, _last_last_say_who if event=="begin": _speaker_changed = (_last_say_who != _last_last_say_who) _last_last_say_who = _last_say_who config.all_character_callbacks.append(speaker_change_callback) default _speaker_changed = False default _last_last_say_who = "" define e = Character("Eileen") define a = Character("Anne") label start: e "1" e "2" a "3" a "4" a "5" e "6" return transform bounce: # random example transform, obvs change if you wish parallel: ease 0.2 yoffset -10 ease 0.2 yoffset 0 parallel: alpha 0.0 linear 0.4 alpha 1.0 screen say(who, what): style_prefix "say" window: id "window" if who is not None: window: ## two lines added to default say screen otherwise no changes if _speaker_changed: at bounce id "namebox" style "namebox" text who id "who" text what id "what" ## If there's a side image, display it above the text. Do not display on the ## phone variant - there's no room. if not renpy.variant("small"): add SideImage() xalign 0.0 yalign 1.0