Problem with call stack
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.
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.
Problem with call stack
In the program, I add a label to the return stack
renpy.set_return_stack (renpy.get_return_stack () + 'onEnterLabel')
the program crashes
renpy.set_return_stack (renpy.get_return_stack () + 'onEnterLabel')
the program crashes
- Remix
- Eileen-Class Veteran
- Posts: 1628
- Joined: Tue May 30, 2017 6:10 am
- Completed: None... yet (as I'm still looking for an artist)
- Projects: An un-named anime based trainer game
- Contact:
Re: Problem with call stack
Any traceback / error report?
The return stack (for rollforward and back) is held in a list format, so could only be added to another list or appended to with a list method call.
Realistically, it is not really something you want to be changing unless you really know what you are doing...
The return stack (for rollforward and back) is held in a list format, so could only be added to another list or appended to with a list method call.
Realistically, it is not really something you want to be changing unless you really know what you are doing...
Frameworks & Scriptlets:
- Speech Bubble dialogue system
- Multiple Notify with ATL and history
- (WIP) Radial Masking - needs updating to use Shader
- 7.4 - Smooth Tinting using ATL and matrixcolor
- Several other repositories there too
Re: Problem with call stack
I have class
class Location:
def __init__ (self):
self.onEnterList = []
def onEnter (self, label):
self.onEnterList.append (label)
On every event I can call onEnterList to attach it.
At each change of location calls
label onChangeLocation:
$ renpy.set_return_stack (renpy.get_return_stack () + location.onEnterList)
return
In version 6.99.12.4 it's OK.
class Location:
def __init__ (self):
self.onEnterList = []
def onEnter (self, label):
self.onEnterList.append (label)
On every event I can call onEnterList to attach it.
At each change of location calls
label onChangeLocation:
$ renpy.set_return_stack (renpy.get_return_stack () + location.onEnterList)
return
In version 6.99.12.4 it's OK.
Re: Problem with call stack
Still not seeing the error message?
- Remix
- Eileen-Class Veteran
- Posts: 1628
- Joined: Tue May 30, 2017 6:10 am
- Completed: None... yet (as I'm still looking for an artist)
- Projects: An un-named anime based trainer game
- Contact:
Re: Problem with call stack
Not 'really' knowing what you are trying to achieve and not knowing any error or traceback I can only suggest some overview...
renpy.set_return_stack( stack ) will set the stack to stack. It will then test the length and (if greater than previous) will pad out the dynamic variables with empty dictionaries (thus likely losing any store variables in the new stacks) ... (if less) it will backport the current dynamics into the final stack index (effectively preserving store variables from now into back then)
As I say, meddling with the context stack is not to be done lightly...
If you are only adding your label references (or whatever) between interactions, I might suggest looking at renpy.checkpoint() instead or just assuring that some changing variable (e.g. current_location) is included in the store ( use default to set it or at a huge push maybe renpy.game.context.make_dynamic( [ var name as string ] ) ) so it participates in rollback and registers as changed in any checkpoint.
renpy.set_return_stack( stack ) will set the stack to stack. It will then test the length and (if greater than previous) will pad out the dynamic variables with empty dictionaries (thus likely losing any store variables in the new stacks) ... (if less) it will backport the current dynamics into the final stack index (effectively preserving store variables from now into back then)
As I say, meddling with the context stack is not to be done lightly...
If you are only adding your label references (or whatever) between interactions, I might suggest looking at renpy.checkpoint() instead or just assuring that some changing variable (e.g. current_location) is included in the store ( use default to set it or at a huge push maybe renpy.game.context.make_dynamic( [ var name as string ] ) ) so it participates in rollback and registers as changed in any checkpoint.
Frameworks & Scriptlets:
- Speech Bubble dialogue system
- Multiple Notify with ATL and history
- (WIP) Radial Masking - needs updating to use Shader
- 7.4 - Smooth Tinting using ATL and matrixcolor
- Several other repositories there too
Re: Problem with call stack
I want to separate locations and events. For example I make locations
river = Location ('river')
forest = Location ('forest')
And events
river.onEnter ('labelEvent1')
river.onEnter ('labelEvent2')
forest.onEnter ('labelEvent3')
forest.onEnter ('labelEvent4')
On enter in river or forest should be called labels. I did
for item in ['label1', 'label2']: renpy.call (item)
but is called only one label. I added labels to the stack, but in version 7 this does not work.
river = Location ('river')
forest = Location ('forest')
And events
river.onEnter ('labelEvent1')
river.onEnter ('labelEvent2')
forest.onEnter ('labelEvent3')
forest.onEnter ('labelEvent4')
On enter in river or forest should be called labels. I did
for item in ['label1', 'label2']: renpy.call (item)
but is called only one label. I added labels to the stack, but in version 7 this does not work.
Re: Problem with call stack
Change your for loop into a while loop with a pointer:
Pseudo code (may work, probably not knowing my coding abilities):
The reason your loop only calls the first label is because you can't return from a call to specific Python statements, only Renpy statements. So it skips the python block when it returns from the call.
Since you still haven't posted the error messages you got from the call stack (that Remix and I asked multiple times), we can't help you with the callstack issue. Once again, no error code, can't begin to diagnose. If you'd posted error codes: Remix could probably have given you an answer in 2 seconds
However the above is how I navigate around calling labels within a loop.
Pseudo code (may work, probably not knowing my coding abilities):
Code: Select all
$ labels = ['label1', 'label2']
$ pointer = len(labels)
while pointer >= 0:
pointer -= 1
call expression labels[pointer]
Since you still haven't posted the error messages you got from the call stack (that Remix and I asked multiple times), we can't help you with the callstack issue. Once again, no error code, can't begin to diagnose. If you'd posted error codes: Remix could probably have given you an answer in 2 seconds
However the above is how I navigate around calling labels within a loop.
Re: Problem with call stack
Error with stack "IndexError: pop from empty list"
Thanks.
Thanks.
Re: Problem with call stack
Can you paste the entire error log? We can guess it's the return stack that's empty, but would be helpful to see more.
Have you looked at my code suggestion above? It should solve your problem without needing to play with the return stack.
Have you looked at my code suggestion above? It should solve your problem without needing to play with the return stack.
Re: Problem with call stack
I have seen. Thanks
I'm sorry, but an uncaught exception occurred.
While running game code:
File "game/locations/Outside the Mansion.rpy", line 10, in script
return
IndexError: pop from empty list
-- Full Traceback ------------------------------------------------------------
Full traceback:
File "game/locations/Outside the Mansion.rpy", line 10, in script
return
File "d:\disa\renpy-7.0.0-sdk\renpy\ast.py", line 1448, in execute
next_node(renpy.game.context().lookup_return(pop=True))
File "d:\disa\renpy-7.0.0-sdk\renpy\execution.py", line 682, in lookup_return
self.abnormal = self.abnormal_stack.pop()
IndexError: pop from empty list
Windows-XP-5.1.2600-SP3
Ren'Py 7.0.0.196
etranz 0.0
Wed Jun 06 15:27:56 2018
I'm sorry, but an uncaught exception occurred.
While running game code:
File "game/locations/Outside the Mansion.rpy", line 10, in script
return
IndexError: pop from empty list
-- Full Traceback ------------------------------------------------------------
Full traceback:
File "game/locations/Outside the Mansion.rpy", line 10, in script
return
File "d:\disa\renpy-7.0.0-sdk\renpy\ast.py", line 1448, in execute
next_node(renpy.game.context().lookup_return(pop=True))
File "d:\disa\renpy-7.0.0-sdk\renpy\execution.py", line 682, in lookup_return
self.abnormal = self.abnormal_stack.pop()
IndexError: pop from empty list
Windows-XP-5.1.2600-SP3
Ren'Py 7.0.0.196
etranz 0.0
Wed Jun 06 15:27:56 2018
Re: Problem with call stack
That's way beyond me, clearly the stack's getting emptied before the return statements, so your manipulation of the return stack isn't working as intended.
Does my code not work for you, or do you just prefer directly manipulating the call_stack despite the error?
Your minimalist replies makes it very hard to tell if you're just not interested in the alternative to the call_stack method or not...
Does my code not work for you, or do you just prefer directly manipulating the call_stack despite the error?
Your minimalist replies makes it very hard to tell if you're just not interested in the alternative to the call_stack method or not...
- Remix
- Eileen-Class Veteran
- Posts: 1628
- Joined: Tue May 30, 2017 6:10 am
- Completed: None... yet (as I'm still looking for an artist)
- Projects: An un-named anime based trainer game
- Contact:
Re: Problem with call stack
The error seems to imply Ren'Py is expecting abnormality in the stack (possibly due to testing lengths after the return stack changes) and yet is not finding an item within the abnormal_stack... presumably you would need to set that as well or delve through the code and find what is registering it as abnormal.
Rather than try to get that working that way though, (as most every part of me is saying that is likely not the best solution for the problem) perhaps you could fully explain what you are trying to achieve and we could maybe suggest alternatives.
kivik has already suggested bringing that game logic down into a label control flow and using a while loop in there which would work, wouldn't unduly mess with Ren'Py and would work with save/rollback/forward
Rather than try to get that working that way though, (as most every part of me is saying that is likely not the best solution for the problem) perhaps you could fully explain what you are trying to achieve and we could maybe suggest alternatives.
kivik has already suggested bringing that game logic down into a label control flow and using a while loop in there which would work, wouldn't unduly mess with Ren'Py and would work with save/rollback/forward
Frameworks & Scriptlets:
- Speech Bubble dialogue system
- Multiple Notify with ATL and history
- (WIP) Radial Masking - needs updating to use Shader
- 7.4 - Smooth Tinting using ATL and matrixcolor
- Several other repositories there too
- PyTom
- Ren'Py Creator
- Posts: 16096
- Joined: Mon Feb 02, 2004 10:58 am
- Completed: Moonlight Walks
- Projects: Ren'Py
- IRC Nick: renpytom
- Github: renpytom
- itch: renpytom
- Location: Kings Park, NY
- Contact:
Re: Problem with call stack
I could point out the problem here - you're not giving set_return_stack the right type.
But seriously, this is very powerful magic, and I can't see anything here that justifies the use of the function. If you want to let us know what you're really trying to accomplish, we can help you with that - manipulating the return stack is very very unlikely to be the right answer.
But seriously, this is very powerful magic, and I can't see anything here that justifies the use of the function. If you want to let us know what you're really trying to accomplish, we can help you with that - manipulating the return stack is very very unlikely to be the right answer.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom(When was the last time you backed up your game?)
Software > Drama • https://www.patreon.com/renpytom
Who is online
Users browsing this forum: Majestic-12 [Bot], piinkpuddiin, snotwurm