Page 1 of 1

KeyError: 'retain' when calling say with name argument

Posted: Sun Mar 31, 2024 8:04 am
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.

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

Posted: Sun Mar 31, 2024 2:52 pm
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.

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

Posted: Sun Mar 31, 2024 3:11 pm
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")

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

Posted: Sun Mar 31, 2024 3:36 pm
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, ...)

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

Posted: Sun Mar 31, 2024 5:16 pm
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.