Ren'Py Help with showing a screen from another screen.

Milvidi

Member
Game Developer
Feb 26, 2018
200
540
So, I need to so another screen (with argument) from another screen.
First I have two objects like this:
Code:
test_dungeon_1st_floor = Dungeon(
            name = "Test Dungeon 1st Floor",
            bg = "test_dungeon_bg.webp",
            progress = 0,
            mob_spawn = [slime]
         )

slime = Enemy(
            name = "Slime",
            hp = 30,
            max_hp = 30,
            lvl = 1,
            atk = 5,
            defense = 1,
            spd = 1
        )
Then I have these two screens:
Code:
screen dungeon_scr(dungeon, next_floor=False):
    zorder 0
    add dungeon.bg
    frame:
        xalign 0.1
        yalign 0.1
        vbox:
            spacing 10
            text dungeon.name
            bar:
                value dungeon.progress
                range 100
            textbutton "Search around" action SetField(dungeon, "progress", dungeon.progress + 10)
            textbutton "Search for enemy" action Show("enemy_scr", dungeon.mob_spawn) <------- The problem is here
            textbutton "Next floor" action [SetField(dungeon, "progress", 0), Jump(next_floor)] sensitive dungeon.progress > 99 and next_floor != False

screen enemy_scr(mob):
    zorder 1
    python:
        while len(enemy_list) < 10:
            enemy_to_add = renpy.random.choice(mob)
            enemy_list.append(enemy_to_add)
    frame:
        vbox:
            spacing 10   
            for enemy in enemy_list:           
                text enemy.name
I want the enemy_scr to show when I press the "Search for enemy" button from the dungeon_scr, but all I got is this error:
Code:
```
I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/declaration.rpy", line 104, in script
    call screen dungeon_scr(test_dungeon_1st_floor, "Test_Dungeon_2nd_Floor")
  File "renpy/common/000statements.rpy", line 609, in execute_call_screen
    store._return = renpy.call_screen(name, *args, **kwargs)
TypeError: 'RevertableList' object is not callable

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

Full traceback:
  File "game/declaration.rpy", line 104, in script
    call screen dungeon_scr(test_dungeon_1st_floor, "Test_Dungeon_2nd_Floor")
  File "D:\Renpy 8\renpy\ast.py", line 2232, in execute
    self.call("execute")
  File "D:\Renpy 8\renpy\ast.py", line 2220, in call
    return renpy.statements.call(method, parsed, *args, **kwargs)
  File "D:\Renpy 8\renpy\statements.py", line 281, in call
    return method(parsed, *args, **kwargs)
  File "renpy/common/000statements.rpy", line 609, in execute_call_screen
    store._return = renpy.call_screen(name, *args, **kwargs)
  File "D:\Renpy 8\renpy\exports.py", line 3181, in call_screen
    rv = renpy.ui.interact(mouse="screen", type="screen", roll_forward=roll_forward)
  File "D:\Renpy 8\renpy\ui.py", line 299, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "D:\Renpy 8\renpy\display\core.py", line 3377, in interact
    repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, pause=pause, pause_start=pause_start, pause_modal=pause_modal, **kwargs) # type: ignore
  File "D:\Renpy 8\renpy\display\core.py", line 3752, in interact_core
    trans = self.ongoing_transition[None](
TypeError: 'RevertableList' object is not callable

Windows-10-10.0.19044 AMD64
Ren'Py 8.0.3.22090809
Dungeon and Combat 1.0
Sat Jan 21 05:33:57 2023
```
When I try to show the screen by typing show screen in the console it works fine, but not when using the button. Is there anyway to make this works other than make the button jump to another label then call the screen there instead?
 

MidnightArrow

Active Member
Aug 22, 2021
500
451
The error message means it's trying to call dungeon.mob_spawn like it's a Python function even though it isn't. Looking at the full traceback it's interrupted during "ongoing_transition".

The say that Show() expects a transition after the screen name so it looks like it's trying to access mob_spawn as a transition?

Try making it a keyword argument instead. action Show("enemy_scr", mob=dungeon.mob_spawn)
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,976
16,232
When I try to show the screen by typing show screen in the console it works fine, but not when using the button.

The screen action expect the screen name as first parameter, and a transition as second one. Therefore, here it believe that "dungeon.mob_spawn" is this second parameter.

What you need is either to specifically pass an empty transition, Show("enemy_scr", None, dungeon.mob_spawn), or force the arguments for your screen to be keywords arguments:
Python:
screen enemy_scr( mob=[]):
    [...]
Then pass your list as explicit keyword argument, Show("enemy_scr", mob=dungeon.mob_spawn).