How to discard the entire call stack?

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
qwertyu63
Newbie
Posts: 6
Joined: Mon Apr 19, 2021 8:19 pm
itch: qwertyu63
Contact:

How to discard the entire call stack?

#1 Post by qwertyu63 »

I need a way to discard the entire call stack.

I have a complex combat system that, depending on the situation, could be started with a few locations stacked up in the "return from call" stack. I would like to make it so if you completely lose a battle in certain situations, it sends you to a specific location (the player is being sent home to heal), but this would result in a memory leak of sorts, as I'm left with a potentially large call stack that will never be returned to.

When a failure like this happens, I no longer need that call stack (it contains the locations the player went through to get to the battle, and they are no longer there), so I need a way to completely flush the stack.

I already know how to remove the top value with renpy.pop_call(), but in this case, I need to remove the entire stack; assume the height of the stack could vary (so I can't just use pop_call() the "right" number of times).

User avatar
emz911
Regular
Posts: 103
Joined: Fri Jun 23, 2017 2:23 pm
Contact:

Re: How to discard the entire call stack?

#2 Post by emz911 »


qwertyu63
Newbie
Posts: 6
Joined: Mon Apr 19, 2021 8:19 pm
itch: qwertyu63
Contact:

Re: How to discard the entire call stack?

#3 Post by qwertyu63 »

emz911 wrote: Mon Jul 19, 2021 12:58 am Set https://www.renpy.org/doc/html/label.ht ... turn_stack to an empty list []
Perfect. Thank you.

Post Reply

Who is online

Users browsing this forum: No registered users