Returning from Ren'py call stack to Python 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
FortOyer
Newbie
Posts: 6
Joined: Tue May 20, 2014 12:50 pm
Contact:

Returning from Ren'py call stack to Python call stack.

#1 Post by FortOyer »

I have my program set up with quite a few function callbacks, these functions can be expected to use renpy.call, and then continue where they left off. Unfortunately the renpy.call kills the python function before it'd complete gracefully.

Calling in a new context would work, but the new context wouldn't save any dialogue in the call statement to rollback.

Here's a general example where setting t to "Last Call" never happens.

Code: Select all

define e = Character('Eileen', color="#c8ffc8")

init:
    define t = "Initial Value"

init python:
        def func():
            store.t = "Second Pass"
            
        def func2():
            renpy.call("stack_test")
            store.t = "Last Call"
 
label stack_test:
    $ t = "Penultimate Call"
    e "[t]"
    return 
    
# The game starts here.
label start:
    e "[t]"
    $ func()
    e "[t]"
    $ func2()
    e "[t]"    
    return

Is there a workaround for this?

User avatar
Milkymalk
Miko-Class Veteran
Posts: 753
Joined: Wed Nov 23, 2011 5:30 pm
Completed: Don't Look (AGS game)
Projects: KANPEKI! ★Perfect Play★
Organization: Crappy White Wings
Location: Germany
Contact:

Re: Returning from Ren'py call stack to Python call stack.

#2 Post by Milkymalk »

I had the same problem. Unfortunately, renpy.call() always aborts the Python stack and returns to the Ren'py script. You should try to avoid using renpy.call(), which means only executing functions when you are sure you don't need to call a label inbetween.

Fortunately, you can call labels with arguments and then include a Python block if necessary to "imitate" Python functions:

Code: Select all

label callme(a):
    ..stuff..
    python:
        ..stuff..
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)

FortOyer
Newbie
Posts: 6
Joined: Tue May 20, 2014 12:50 pm
Contact:

Re: Returning from Ren'py call stack to Python call stack.

#3 Post by FortOyer »

Damn and damn! Ah well, will redesign with that in mind, thank-you! :)

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Returning from Ren'py call stack to Python call stack.

#4 Post by xela »

Milkymalk is right, there is nothing you can do here... but there is always a workaround (in this case a workaround will prolly result in better code).
Like what we're doing? Support us at:
Image

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Wildmask