[Solved] - Cant start interaction in the middle of an interaction

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
User avatar
Enchant00
Regular
Posts: 136
Joined: Tue Jan 12, 2016 1:17 am
Contact:

[Solved] - Cant start interaction in the middle of an interaction

#1 Post by Enchant00 »

I have a piece of code more complex but likewise similar to the structure below.

I'm trying to call a function that would in turn call a screen:

Code: Select all

init python:
    def test():
        renpy.call_screen('sample_text')

screen sample_text:
    text 'TESTING IF THIS SCREEN WILL WORK OR NOT' size 100
The function is called when the player presses a button

Code: Select all

screen button_test:
    frame:
        background '#ffffff'
        xysize(50,50)
        align(0.5,0.5)
        button action Function(test) 
In the script i display the button with the call screen button_test

Here is my problem: I'm getting a
I'm sorry, but an uncaught exception occurred.

While running game code:
File "game/script.rpy", line 16, in script
call screen button_test
File "renpy/common/000statements.rpy", line 485, in execute_call_screen
store._return = renpy.call_screen(name, *args, **kwargs)
File "renpy/common/00action_other.rpy", line 501, in __call__
rv = self.callable(*self.args, **self.kwargs)
File "game/test screen.rpy", line 3, in test
renpy.call_screen('sample_text')
Exception: Cannot start an interaction in the middle of an interaction, without creating a new context.

So far I really have no clue what that means by interaction in the middle of another :lol: I saw a similar post here viewtopic.php?t=18843 but even then I can't really wrap my head around this. Also, I can't just simply use the call screen to directly call the sample_text since in my program the screen call is directly coming from a python block inside a class method. Anyway, any help is appreciated and thanks in advance.
Last edited by Enchant00 on Sat Mar 31, 2018 3:00 am, edited 1 time in total.

User avatar
Milkymalk
Miko-Class Veteran
Posts: 760
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: Help - Cant start interaction in the middle of an interaction

#2 Post by Milkymalk »

An interaction means "Ren'Py is waiting for user input". This can be a line of dialogue (click to continue) or a screen call (stop script until the screen returns something). So when you call one screen, you can't call another screen until that first call is completely resolved, because you are in an interaction and can't create another one.
To do that, you have to call the new interaction in a new context:
https://www.renpy.org/doc/html/label.ht ... ew_context

You can imagine a new context like a pocket dimension. After you return from it, everything will be just like you left it.

If the second screen is not supposed to return anything, you could still just show it instead of calling it.
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)

User avatar
Enchant00
Regular
Posts: 136
Joined: Tue Jan 12, 2016 1:17 am
Contact:

Re: Help - Cant start interaction in the middle of an interaction

#3 Post by Enchant00 »

WOW I get it now thanks :x You really helped me a bunch.My screen returns an input so I have to use the new context invoke.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]