[Solved] Dynamic Character Name Not Being Remembered

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
yukiko
Newbie
Posts: 7
Joined: Sat Nov 21, 2015 12:26 am
Contact:

[Solved] Dynamic Character Name Not Being Remembered

#1 Post by yukiko »

In my game I have included an "Ending List" under the Extras menu so that after obtaining endings, players can "replay" the endings again. The "Replay" feature works fine however when I replay the ending, it appears "blank" where the protagonist's name should be. All the other names for the characters appear, though.

I know this is probably because the protagonist's name is changeable but I'm not sure how to code it so that the game remembers the protagonist's name (I'm assuming you use persistent data?)
I would like it to remember the exact name the player chose when they replay the endings.

Is there a way to do this? I'd appreciate any help.

Thanks.
Last edited by yukiko on Sun Jan 31, 2016 12:21 am, edited 1 time in total.

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: Dynamic Character Name Not Being Remembered

#2 Post by namastaii »

Hmmmmmm....

could you maybe make it so that the ending you replay doesn't actually 'end' the game? It's an ending but it's just a scene you can replay from a certain point?

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Dynamic Character Name Not Being Remembered

#3 Post by PyTom »

The problem is, you're asking the name each time the player plays through. If you do that, the player name can be different for each playthrough - so it doesn't make sense for it to be remembered.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

yukiko
Newbie
Posts: 7
Joined: Sat Nov 21, 2015 12:26 am
Contact:

Re: Dynamic Character Name Not Being Remembered

#4 Post by yukiko »

Thanks for the replies everyone. It's greatly appreciated! ^^
After much fiddling, I finally got it to work how I wanted it! Yay~! (:
I seemed to have been right about using "persistent data". I thought I somehow had to make it a constant, changing "global" variable.
Just as I intended, the dynamic character name is now being remembered no matter how many times I go off and on the game after saving with a certain name or restart the game with a different name it will "replace" the name that appears in the Ending scene replay! I'm super happy!
I knew it was possible to do, I just needed to figure out the correct method to put it into action.
For anyone who needs to accomplish something similar, I'll just mention kind of what I did here:

Just a small snippet of one of the hot spots for my Ending List screen (under screens.rpy):

Code: Select all

            if persistent.bad_end:
                hotspot (394, 114, 225, 34) action Replay("bad_end",locked=not persistent.Replay_bad_end, scope={'protag': persistent.badend_protag})
            else:
                hotspot (394, 114, 225, 34) action None
The important part that made this work how I wanted it is the line: scope={'protag': persistent.badend_protag}

In my script file (under script.rpy) where I define the persistent variable ($ persistent.badend_protag = protag) + where it should "replay" the ending:

Code: Select all

   ...Ending text here...blah blah...
    $ renpy.end_replay()
    $ persistent.Replay_bad_end = True    
    
    $ persistent.bad_end = True 

    if not _in_replay:
        $ persistent.badend_protag = protag
        $ renpy.block_rollback()
        $ renpy.pause(45.0, hard='True')
        scene black with m2
        with Pause(2.0)
        $ renpy.full_restart()
I hope that helps someone with a similar issue. I'm sorry if it's slightly confusing, I tried my best to explain x_x

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: [Solved] Dynamic Character Name Not Being Remembered

#5 Post by namastaii »

I'm glad you figured it out

Post Reply

Who is online

Users browsing this forum: Bing [Bot]