[Solved] Error calling/showing a screen more than once

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
eddie
Newbie
Posts: 4
Joined: Tue Jun 22, 2021 5:15 pm
Contact:

[Solved] Error calling/showing a screen more than once

#1 Post by eddie »

Hey!

I'm having trouble showing my screen "caretBlue". The first time I show it in the script, it works just fine but if I try to show it again, an error occurs.

For context, I'm making a text-based game where the player can input actions. Here's the screen itself:

Code: Select all

screen caretBlue():

    modal True

    zorder 200

    hbox:
        xalign 0.5
        yalign 0.98
        input:
            value VariableInputValue("Action", returnable=True)
            length 32
            copypaste True
            prefix ">"
            suffix "."
            style "caretBox"
        textbutton "OK":
            action [Hide('caretBlue'), Call("Do")]
            keysym('K_RETURN', 'K_KP_ENTER')
            text_style "Proceed"
Here's what it looks like when I show the screen: (i've seperated the script into different files for organisation)

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 41, in script call
    call script1
  File "game/script1.rpy", line 54, in script
    """
  File "renpy/common/00nvl_mode.rpy", line 381, in do_display
    **display_args)
AttributeError: 'list' object has no attribute 'replace'

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

Full traceback:
  File "game/script.rpy", line 41, in script call
    call script1
  File "game/script1.rpy", line 54, in script
    """
  File "D:\Games\renpy-7.3.5-sdk/renpy/ast.py", line 715, in execute
    renpy.exports.say(who, what, *args, **kwargs)
  File "D:\Games\renpy-7.3.5-sdk/renpy/exports.py", line 1417, in say
    who(what, *args, **kwargs)
  File "D:\Games\renpy-7.3.5-sdk/renpy/character.py", line 1219, in __call__
    self.do_display(who, what, cb_args=self.cb_args, dtt=dtt, **display_args)
  File "renpy/common/00nvl_mode.rpy", line 381, in do_display
    **display_args)
  File "D:\Games\renpy-7.3.5-sdk/renpy/character.py", line 621, in display_say
    rv = renpy.ui.interact(mouse='say', type=type, roll_forward=roll_forward)
  File "D:\Games\renpy-7.3.5-sdk/renpy/ui.py", line 298, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "D:\Games\renpy-7.3.5-sdk/renpy/display/core.py", line 3213, in interact
    repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, pause=pause, pause_start=pause_start, **kwargs)
  File "D:\Games\renpy-7.3.5-sdk/renpy/display/core.py", line 3631, in interact_core
    renpy.display.behavior.input_post_per_interact()
  File "D:\Games\renpy-7.3.5-sdk/renpy/display/behavior.py", line 1129, in input_post_per_interact
    i.update_text(content, editable)
  File "D:\Games\renpy-7.3.5-sdk/renpy/display/behavior.py", line 1264, in update_text
    set_content(new_content)
  File "D:\Games\renpy-7.3.5-sdk/renpy/display/behavior.py", line 1259, in set_content
    self.set_text([self.prefix, content[0:self.caret_pos].replace("{", "{{"), edit_text, caret,
AttributeError: 'list' object has no attribute 'replace'

Windows-10-10.0.19041
Ren'Py 7.4.5.1648
My Game 1.0
Tue Jun 22 23:05:09 2021
I also tried to call it instead, and a similar thing happens:

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 41, in script call
    call script1
  File "game/script1.rpy", line 54, in script
    call screen caretBlue
  File "renpy/common/000statements.rpy", line 569, in execute_call_screen
    store._return = renpy.call_screen(name, *args, **kwargs)
AttributeError: 'list' object has no attribute 'replace'

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

Full traceback:
  File "game/script.rpy", line 41, in script call
    call script1
  File "game/script1.rpy", line 54, in script
    call screen caretBlue
  File "D:\Games\renpy-7.3.5-sdk/renpy/ast.py", line 1969, in execute
    self.call("execute")
  File "D:\Games\renpy-7.3.5-sdk/renpy/ast.py", line 1957, in call
    return renpy.statements.call(method, parsed, *args, **kwargs)
  File "D:\Games\renpy-7.3.5-sdk/renpy/statements.py", line 278, in call
    return method(parsed, *args, **kwargs)
  File "renpy/common/000statements.rpy", line 569, in execute_call_screen
    store._return = renpy.call_screen(name, *args, **kwargs)
  File "D:\Games\renpy-7.3.5-sdk/renpy/exports.py", line 3057, in call_screen
    rv = renpy.ui.interact(mouse="screen", type="screen", roll_forward=roll_forward)
  File "D:\Games\renpy-7.3.5-sdk/renpy/ui.py", line 298, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "D:\Games\renpy-7.3.5-sdk/renpy/display/core.py", line 3213, in interact
    repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, pause=pause, pause_start=pause_start, **kwargs)
  File "D:\Games\renpy-7.3.5-sdk/renpy/display/core.py", line 3631, in interact_core
    renpy.display.behavior.input_post_per_interact()
  File "D:\Games\renpy-7.3.5-sdk/renpy/display/behavior.py", line 1129, in input_post_per_interact
    i.update_text(content, editable)
  File "D:\Games\renpy-7.3.5-sdk/renpy/display/behavior.py", line 1264, in update_text
    set_content(new_content)
  File "D:\Games\renpy-7.3.5-sdk/renpy/display/behavior.py", line 1259, in set_content
    self.set_text([self.prefix, content[0:self.caret_pos].replace("{", "{{"), edit_text, caret,
AttributeError: 'list' object has no attribute 'replace'

Windows-10-10.0.19041
Ren'Py 7.4.5.1648
My Game 1.0
Tue Jun 22 23:23:10 2021
I've tried everything I could but nothing seems to work. It seems to be something to do with renpy's code itself, I think.

Any help would be appreciated. Thanks! :mrgreen:
Last edited by eddie on Wed Jun 23, 2021 11:28 am, edited 1 time in total.

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2400
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Error calling/showing a screen more than once

#2 Post by Ocelot »

"Action" is in list of reserved names. It is used internally. Redefining it breaks RenPy.
https://www.renpy.org/doc/html/reserved.html
< < insert Rick Cook quote here > >

User avatar
eddie
Newbie
Posts: 4
Joined: Tue Jun 22, 2021 5:15 pm
Contact:

Re: Error calling/showing a screen more than once

#3 Post by eddie »

Hey there!

I've gone ahead and replaced the variable name "Action" with "Verb", but the problem still persists. Any idea what else it might be?

It seems to be to do with the lines after "show screen caretBlue". When I remove all dialogue after the screen is shown, the game just ends.

Here's what I mean;

The script:

Code: Select all

    """
    Text Text Text
    """

    show screen caretBlue

    extend " Text Text Text"

    """
    Text Text Text
    """
    
    show screen caretBlue
    
     """ ##### where the problem refers to
     Text Text Text
     """
     
    show screen caretBlue


User avatar
Ocelot
Lemma-Class Veteran
Posts: 2400
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Error calling/showing a screen more than once

#4 Post by Ocelot »

Now I also see indentation mismatch: string literal after show screen is indented one extra space.
< < insert Rick Cook quote here > >

User avatar
eddie
Newbie
Posts: 4
Joined: Tue Jun 22, 2021 5:15 pm
Contact:

Re: Error calling/showing a screen more than once

#5 Post by eddie »

Hey.

My bad! I must've done that by mistake while making the example.

In the actual code, this isn't the problem. Sorry about that.

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2400
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Error calling/showing a screen more than once

#6 Post by Ocelot »

Try to isolate problem, create a new project and copy all relevant parts of your code. Make sure it launches and exhibits errorneous behavior. Then start removing everything which is not nessesary. Chances are, you will find source of the problem along the way and either figure out the solution yourself or will be able to post short and concise example, anyone will be able to run and see, what is happening.

Right now I was able to substitute my best guess for the parts of code you din't poste, even though screen clearly uses them, and somewhat replicated your problem:

Code: Select all

screen caretBlue():
    modal True
    hbox:
        align (0.5, 0.5)
        input:
            value VariableInputValue("sss", returnable=True)
        textbutton "OK":
            action [Hide('caretBlue'), Call("Do")]
            keysym('K_RETURN', 'K_KP_ENTER')

default sss = ""

label Do:
    $ sss = list()
    return

label start:
    show screen caretBlue
    '...'
    show screen caretBlue
    '...'
    return
Long story short: make sure your input variable remains a string and is not overwritten by anything else.
< < insert Rick Cook quote here > >

User avatar
eddie
Newbie
Posts: 4
Joined: Tue Jun 22, 2021 5:15 pm
Contact:

Re: Error calling/showing a screen more than once

#7 Post by eddie »

Thanks so much!

Your tip helped me figure out my problem.

Long story short, I had to declare a new variable to store the list in, instead of using the original variable to store the list in.

Post Reply

Who is online

Users browsing this forum: Google [Bot]