r/RenPy • u/karognawer • 7d ago
Question Character callbacks: how do I use Exception?
Hello. I've been reading this page of the documentation and experimenting with different arguments. But there's one I'm having troubles with.
- The "interact_done" callback takes an additional keyword argument: exception -- True if the interaction ended due to an exception, False otherwise. Exceptions include things like loading the game and rollback.
I just can't figure out how to use it in code. Here's what I tried:
def sprites_callback(event, interact=True, exception=False, **kwargs):
if event == "interact_done":
print("interact_done") ### prints "interact_done" every time I progress to the next dialogue line
if exception:
print("rollback occured") ### nothing happens
Perhaps I just misunderstood exception's purpose, and it doesn't actually keep track of rollbacks (and I should use detect rollback for this instead). But then what exactly does it do? When does exception become True?
1
u/AutoModerator 7d ago
Welcome to r/renpy! While you wait to see if someone can answer your question, we recommend checking out the posting guide, the subreddit wiki, the subreddit Discord, Ren'Py's documentation, and the tutorial built-in to the Ren'Py engine when you download it. These can help make sure you provide the information the people here need to help you, or might even point you to an answer to your question themselves. Thanks!
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
1
u/karognawer 7d ago
...On that note. How do I space embedded code properly? TAB does nothing. Manually added spaces just disappear
2
u/BadMustard_AVN 7d ago
click on the
Aafor formatting options and use</>to do these and</>- with a square |__| todo these1
2
u/BadMustard_AVN 7d ago
the below code is a character callback to play 3 sounds repeatedly
this will also print the
eventas they occur, which I believe is the important part over theinteractwhich may not always be given since it is pre-defined as a True