KeyError: 'retain' when calling say with name argument

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
SuIT
Newbie
Posts: 1
Joined: Sun Mar 31, 2024 7:58 am
Contact:

KeyError: 'retain' when calling say with name argument

#1 Post by SuIT »

Hi,
I have a ADV Character that I use for multiple characters. I just replace the name with the actual character.
Now I have the following code:

Code: Select all

default character.sgirl = Character(
    "School Girl",
    who_color = "#8a2be2",
    what_color = "#ffffff",
    what_size = 28,
)

label test:
    sgirl "Hello." (name="Aona")
I just changed my PC and now I get the error:
File ..., line ..., in script
sgirl "Hello." (name="Aona")
KeyError: 'retain'
If I remove the name argument, everything works. But with that, I get an error.

Edit: I also tried it like this:

Code: Select all

$ character.sgirl ("Hello.", name = "Aona")
Still not better.

Edit 2: Okay I just looked and on the old PC I have RenPy Version 8.1.3. There I don't have that problem. On my new PC it was Version 8.2.1. Switched the version on my new PC to 8.1.3 and now the problem's gone. Does anyone still have any idea why that is? Wouldn't want my game to break when if I need to update RenPy.

jeffster
Veteran
Posts: 409
Joined: Wed Feb 03, 2021 9:55 pm
Contact:

Re: KeyError: 'retain' when calling say with name argument

#2 Post by jeffster »

"retain" is probably a new (optional) argument introduced in 8.2
https://renpy.org/doc/html/dialogue.html#Character

It's one of those **args in Character definition.

It looks like for some reason your way to process dialog statements doesn't accept "retain" as a known key.

It might be a bug, or perhaps when you modified something in the dialog handling, it did correspond to that Ren'Py version but gets incompatible somehow with the new versions.

BTW, use "define" for Characters, not "default", because those definitions aren't supposed to change during the game.

jeffster
Veteran
Posts: 409
Joined: Wed Feb 03, 2021 9:55 pm
Contact:

Re: KeyError: 'retain' when calling say with name argument

#3 Post by jeffster »

PS. I just run that test piece on my PC with the current 8.2.1, and it went OK, no errors.
SuIT wrote: Sun Mar 31, 2024 8:04 am

Code: Select all

default character.sgirl = Character(
    "School Girl",
    who_color = "#8a2be2",
    what_color = "#ffffff",
    what_size = 28,
)

label test:
    sgirl "Hello." (name="Aona")

User avatar
m_from_space
Miko-Class Veteran
Posts: 981
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: KeyError: 'retain' when calling say with name argument

#4 Post by m_from_space »

SuIT wrote: Sun Mar 31, 2024 8:04 am Hi,
I have a ADV Character that I use for multiple characters. I just replace the name with the actual character.
Now I have the following code:

Code: Select all

default character.sgirl = Character(
    "School Girl",
    who_color = "#8a2be2",
    what_color = "#ffffff",
    what_size = 28,
)
I'm actually not sure what you are doing here. What is this "character" object you are using and why? I also don't get why you create a single character for multiple names. What's the point? If you want to change the name on the fly, you can just do:

Code: Select all

default sname = "School Girl"

define sgirl = Character("[sname]", ...)
# or
define sgirl = Character(sname, dynamic=True, ...)

label start:
    $ sname = "Aona"
    sgirl "Hey, it's me, Aona..."
So but if you actually change the name quite often, why not create a different character to begin with? I can't wrap my head around it.

You can even derive characters from others.

Code: Select all

define aona = Character("Aona", kind=sgirl, ...)

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

Re: KeyError: 'retain' when calling say with name argument

#5 Post by Ocelot »

m_from_space wrote: Sun Mar 31, 2024 3:36 pm I'm actually not sure what you are doing here. What is this "character" object you are using and why?
https://www.renpy.org/doc/html/dialogue ... cter-store




Are you trying to load save and getting this error afterwards? If so, then default is the problem. Character objects are not supposed to be saved, because their internal workings could change at any time and 8.2 added some fields to the character, which your saved version does not have.
< < insert Rick Cook quote here > >

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Amazon [Bot], Baidu [Spider]