[solved] JumpOutException

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
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:

[solved] JumpOutException

#1 Post by Milkymalk »

The following construction gives me a "JumpOutException" and I don't really know what I did wrong:

Code: Select all

screen waitforevent: ## to make the game do nothing when it's called
    pass
    
label start:
    show screen minigame ## this is what's going on
    call screen waitforevent ## wait until it's done

label testexit: ## this I want to jump to from within the function
    "You found the EXIT."
    return

## ...
python:
    def my_function(): ## this function is called from within the minigame
        renpy.jump_out_of_context('testexit') ## ends the minigame by exiting the context of screen waitforevent
Last edited by Milkymalk on Fri May 18, 2018 10:13 pm, edited 1 time in total.
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)

kivik
Miko-Class Veteran
Posts: 786
Joined: Fri Jun 24, 2016 5:58 pm
Contact:

Re: JumpOutException

#2 Post by kivik »

Can you share the actual error message? And maybe the code to the mini-game that calls the function?

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: JumpOutException

#3 Post by Milkymalk »

I'm sorry, but an uncaught exception occurred.

While running game code:
File "game/script.rpy", line 17, in script
call screen waitforevent
File "renpy/common/000statements.rpy", line 519, in execute_call_screen
store._return = renpy.call_screen(name, *args, **kwargs)
File "renpy/common/00action_other.rpy", line 506, in __call__
rv = self.callable(*self.args, **self.kwargs)
File "game/dungeon.rpy", line 91, in dungeon_walk
endturn('step')
File "game/dungeon.rpy", line 108, in endturn
event.checktrigger(what)
File "game/dungeon.rpy", line 26, in checktrigger
renpy.jump_out_of_context(self.label)
JumpOutException: testexit

-- Full Traceback ------------------------------------------------------------

Full traceback:
File "D:\Programme\Ren'py\renpy-6.99.12.4-sdk\renpy\bootstrap.py", line 306, in bootstrap
renpy.main.main()
File "D:\Programme\Ren'py\renpy-6.99.12.4-sdk\renpy\main.py", line 513, in main
run(restart)
File "D:\Programme\Ren'py\renpy-6.99.12.4-sdk\renpy\main.py", line 139, in run
renpy.execution.run_context(True)
File "D:\Programme\Ren'py\renpy-6.99.12.4-sdk\renpy\execution.py", line 846, in run_context
context.run()
File "game/script.rpy", line 17, in script
call screen waitforevent
File "D:\Programme\Ren'py\renpy-6.99.12.4-sdk\renpy\ast.py", line 1828, in execute
self.call("execute")
File "D:\Programme\Ren'py\renpy-6.99.12.4-sdk\renpy\ast.py", line 1816, in call
return renpy.statements.call(method, parsed, *args, **kwargs)
File "D:\Programme\Ren'py\renpy-6.99.12.4-sdk\renpy\statements.py", line 177, in call
return method(parsed, *args, **kwargs)
File "renpy/common/000statements.rpy", line 519, in execute_call_screen
store._return = renpy.call_screen(name, *args, **kwargs)
File "D:\Programme\Ren'py\renpy-6.99.12.4-sdk\renpy\exports.py", line 2664, in call_screen
rv = renpy.ui.interact(mouse="screen", type="screen", roll_forward=roll_forward)
File "D:\Programme\Ren'py\renpy-6.99.12.4-sdk\renpy\ui.py", line 287, in interact
rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
File "D:\Programme\Ren'py\renpy-6.99.12.4-sdk\renpy\display\core.py", line 2635, in interact
repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, **kwargs)
File "D:\Programme\Ren'py\renpy-6.99.12.4-sdk\renpy\display\core.py", line 3437, in interact_core
rv = root_widget.event(ev, x, y, 0)
File "D:\Programme\Ren'py\renpy-6.99.12.4-sdk\renpy\display\layout.py", line 986, in event
rv = i.event(ev, x - xo, y - yo, cst)
File "D:\Programme\Ren'py\renpy-6.99.12.4-sdk\renpy\display\layout.py", line 986, in event
rv = i.event(ev, x - xo, y - yo, cst)
File "D:\Programme\Ren'py\renpy-6.99.12.4-sdk\renpy\display\layout.py", line 986, in event
rv = i.event(ev, x - xo, y - yo, cst)
File "D:\Programme\Ren'py\renpy-6.99.12.4-sdk\renpy\display\screen.py", line 689, in event
rv = self.child.event(ev, x, y, st)
File "D:\Programme\Ren'py\renpy-6.99.12.4-sdk\renpy\display\layout.py", line 986, in event
rv = i.event(ev, x - xo, y - yo, cst)
File "D:\Programme\Ren'py\renpy-6.99.12.4-sdk\renpy\display\behavior.py", line 439, in event
rv = run(action)
File "D:\Programme\Ren'py\renpy-6.99.12.4-sdk\renpy\display\behavior.py", line 315, in run
return action(*args, **kwargs)
File "renpy/common/00action_other.rpy", line 506, in __call__
rv = self.callable(*self.args, **self.kwargs)
File "game/dungeon.rpy", line 91, in dungeon_walk
endturn('step')
File "game/dungeon.rpy", line 108, in endturn
event.checktrigger(what)
File "game/dungeon.rpy", line 26, in checktrigger
renpy.jump_out_of_context(self.label)
File "D:\Programme\Ren'py\renpy-6.99.12.4-sdk\renpy\exports.py", line 1626, in jump_out_of_context
raise renpy.game.JumpOutException(label)
JumpOutException: testexit

Windows-8-6.2.9200
Ren'Py 6.99.14.2.3333
Dungeoncrawl 1.0
Fri May 18 01:53:51 2018
The code is not really that interesting in this regard and not that easy to evaluate. In essence, you press keys that are bound to functions that change variables. After each keypress, a set of if-checks occurs and if they give the right results, the jump is initiated. No other jumps or calls except function calls occur during the "minigame".

Code: Select all

screen minigame:
    key "K_UP" action Function(dungeon_walk, 0)
    key "K_LEFT" action Function(dungeon_turn, -1)
    key "K_RIGHT" action Function(dungeon_turn, 1)
    key "K_DOWN" action Function(dungeon_walk, 2)
    key "K_SPACE" action Jump('event')
    ## and lots of "if" and "add" statements
dungeon_walk and dungeon_turn change some simple variables and end with a function call to endturn(what):

Code: Select all

    def endturn(what):
        for event in currentlevel.events:
            event.checktrigger(what)
And checktrigger() is defined inside a class as:

Code: Select all

        def checktrigger(self, action):
            if self.active:
                if self.coords == (party_x, party_y) and (2**party_heading & self.facing):
                    if (self.type == "auto") or (self.type == action):
                        ## trigger this action
                        if not self.repeat:
                            self.active == False
                        renpy.jump_out_of_context(self.label)
The label "testexit" exists:

Code: Select all

label testexit:
    "You found the EXIT."
    return
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)

kivik
Miko-Class Veteran
Posts: 786
Joined: Fri Jun 24, 2016 5:58 pm
Contact:

Re: JumpOutException

#4 Post by kivik »

Have you had a look at the other forum posts with the same error (from google searching "jumpoutexception")? PyTom mentions menu context in this thread: viewtopic.php?t=8515

But that may be relating to them using the call in the main_menu label more than anything, but either way there's something about the context not being there it seems?

Any particularly reason you can't just jump and have to jump out of context? Is it because of the waitforevent screen? Why don't you call the minigame screen instead of showing it? Is it because any input immediately completes the interaction? If so would a screen with modal True get around that?

Sorry just spitballing here and I'm not familiar with the error!

User avatar
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: JumpOutException

#5 Post by Remix »

We'd actually want to see the code where you are creating/calling the new context to see where the Exception is handled in order to back track.

Are you using renpy.call_in_new_context(label, *args, **kwargs) or invoking a function with renpy.invoke_in_new_context(callable, *args, **kwargs) in order to start your game section?
Frameworks & Scriptlets:

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: JumpOutException

#6 Post by Milkymalk »

@kivik:
I have read the thread and I think the problem there was that there was no parent context to return to. I called the screen so I have the main context and the called context.
I have to jump from the python function and I couldn't find a python equivalent of a simple jump. I guess I have to jump out of context because python only is executed while in a context of its own or something.
The reason I don't call the mini game is because I want to be able to execute renpy script while the game is running, so when I need that I just end the called dummy context, execute the script and then call the dummy screen again.

@Remix:
Look at the very last line of checktrigger(self, action) :)

Code: Select all

        def checktrigger(self, action):
            if self.active:
                if self.coords == (party_x, party_y) and (2**party_heading & self.facing):
                    if (self.type == "auto") or (self.type == action):
                        ## trigger this action
                        if not self.repeat:
                            self.active == False
                        renpy.jump_out_of_context(self.label)
Are you using renpy.call_in_new_context(label, *args, **kwargs) or invoking a function with renpy.invoke_in_new_context(callable, *args, **kwargs) in order to start your game section?
I'm not sure what you mean. I use "show" to show the screen that handles the minigame, "call" to "stun" the execution of renpy script, the minigame uses plain function calls (or rather, the screen action for that) to execute game logic, and one of those functions uses " renpy.jump_out_of_context(label)" to end the minigame.
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)

kivik
Miko-Class Veteran
Posts: 786
Joined: Fri Jun 24, 2016 5:58 pm
Contact:

Re: JumpOutException

#7 Post by kivik »

This is the python statement to jump:

https://www.renpy.org/doc/html/statemen ... .html#jump

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: JumpOutException

#8 Post by Milkymalk »

I feel stupid now. Thank you! I couldn't find it here https://www.renpy.org/doc/html/label.ht ... -functions so I assumed it doesn't exist... :oops:

This makes me assume that jump_out_of_context is only usable when you actually "call_in_new_context" something, which makes sense. Apparently I mixed up "interaction" and "context".
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)

kivik
Miko-Class Veteran
Posts: 786
Joined: Fri Jun 24, 2016 5:58 pm
Contact:

Re: JumpOutException

#9 Post by kivik »

Don't feel stupid! The documentation's structure could be better - but PyTom's only one person so it's a lot to juggle developing the engine, updating docs, and checking forums, and probably a full time job!

Yeah I didn't quite figure out what specifically context means (probably in the docs mind you) in this er... context :P So I was hoping the other thread may make more sense to you without seeing your mini game function. I didn't understand why you didn't just do a jump when I saw your code, but worried I'd sound stupid if I'd suggested it in case you were doing some special stuff with context - so it's good that you mentioned a simple jump was exactly what you wanted to do :)

User avatar
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: JumpOutException

#10 Post by Remix »

I listed those two functions as they are the only place you can use jump_out_of_context without trapping the exception (unless you wrote your own try:except)

A basic non menu usage would be when using something like a pygame script that doesn't play nicely with Ren'Py...

Code: Select all

label a:
    "start"
    $ renpy.call_in_new_context( "pygame_label" )

label pygame_label:
    # run your pygame (no rollback or save features here)
    $ renpy.jump_out_of_context( "after_game", result="win" )

label after_game( result="fail" ):
    "[result]"
    # now we can save etc as we are back in the normal game context
Well, that's how I presume all that gubbins works
Frameworks & Scriptlets:

Post Reply

Who is online

Users browsing this forum: No registered users