Persistent Data in an Extra Story? [SOLVED]

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
DiamondDust132
Newbie
Posts: 19
Joined: Thu Sep 28, 2017 2:38 am
Organization: Team Requiem
itch: team-requiem
Location: Chicago, IL
Contact:

Persistent Data in an Extra Story? [SOLVED]

#1 Post by DiamondDust132 » Thu Feb 07, 2019 6:42 pm

This has been driving me crazy all day, so any help would be appreciated. Basically, my game allows you to name the main character. That's worked like a charm for the main story, but I can't get the persistent data to work in the extra story I've added. I'm presuming it's because of the way I've coded, but I've no idea how to fix the issue. What I'm presuming is the game loads the bonus scene up first, skipping the input section in the script and anything already in the save data. Again, any help would be nice.

Here's how I've got the extra scene put on the main menu if you beat the two routes in the game.

Code: Select all

if main_menu:

            textbutton _("Start") action Start()

            if persistent.IchigoClear and persistent.IchikaClear:
                textbutton _("Bonus") action Start('bonus')
And I get this error upon loading up the extra route. Again, it's not finding the name.

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/Bonus.rpy", line 10, in script
    AY "Oh, boy. Here we go..."
KeyError: u'name'

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

Full traceback:
  File "game/Bonus.rpy", line 10, in script
    AY "Oh, boy. Here we go..."
  File "C:\Users\Aaron Mays\Downloads\RenPy\renpy-6.99.12.4-sdk\renpy\ast.py", line 678, in execute
    renpy.exports.say(who, what, interact=self.interact, *args, **kwargs)
  File "C:\Users\Aaron Mays\Downloads\RenPy\renpy-6.99.12.4-sdk\renpy\exports.py", line 1229, in say
    who(what, *args, **kwargs)
  File "C:\Users\Aaron Mays\Downloads\RenPy\renpy-6.99.12.4-sdk\renpy\character.py", line 1012, in __call__
    who = who_pattern.replace("[who]", sub(who))
  File "C:\Users\Aaron Mays\Downloads\RenPy\renpy-6.99.12.4-sdk\renpy\character.py", line 1007, in sub
    return renpy.substitutions.substitute(s, scope=scope, force=force, translate=translate)[0]
  File "C:\Users\Aaron Mays\Downloads\RenPy\renpy-6.99.12.4-sdk\renpy\substitutions.py", line 244, in substitute
    s = formatter.vformat(s, (), kwargs)
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/string.py", line 563, in vformat
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/string.py", line 585, in _vformat
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/string.py", line 646, in get_field
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/string.py", line 605, in get_value
KeyError: u'name'

Windows-8-6.2.9200
Ren'Py 7.1.3.1092
Gemini ~ Team Requiem 1.0
Thu Feb 07 16:39:12 2019
And this is how I have the name input set up in the script.

Code: Select all

$ name = renpy.input("What's your name?", default="Ayumu", length=10)
    $ name = name.strip()
    $ persistent.name = "[name]"
    $ renpy.save_persistent()
 
Last edited by DiamondDust132 on Fri Feb 08, 2019 4:03 pm, edited 1 time in total.

User avatar
mitoky
Veteran
Posts: 316
Joined: Sat Feb 07, 2015 9:12 pm
Projects: The Purring Demon's Love, circus eterie
Contact:

Re: Persistent Data in an Extra Story?

#2 Post by mitoky » Thu Feb 07, 2019 7:22 pm

Can you try this out?

Code: Select all

    $ name = renpy.input("What's your name?", default="Ayumu", length=10)
    $ name = name.strip()
    $ persistent.name = name

User avatar
Wight
Regular
Posts: 47
Joined: Mon Jan 07, 2019 5:40 pm
Completed: A Transient Experiment
itch: wight
Contact:

Re: Persistent Data in an Extra Story?

#3 Post by Wight » Thu Feb 07, 2019 7:43 pm

Also, if you haven't already done so, try putting this at the beginning of the Bonus chapter after making the adjustment mitoky suggested:

Code: Select all

$ name = persistent.name
I think the way this works is that the game remembers the persistent flag for the original playthrough's name, and this tells it to copy that flag and set it as the name for the new playthrough in the Bonus chapter. Otherwise it might give an error or fall back on the default name.

Or you can use "[persistent.name]" instead of "[name]" for the dialogue in the Bonus chapter. I'm noticing that works too.

User avatar
DiamondDust132
Newbie
Posts: 19
Joined: Thu Sep 28, 2017 2:38 am
Organization: Team Requiem
itch: team-requiem
Location: Chicago, IL
Contact:

Re: Persistent Data in an Extra Story?

#4 Post by DiamondDust132 » Thu Feb 07, 2019 7:46 pm

Haha! That did it! Thanks a lot to both of you. I was about to tear my hair out there.

User avatar
mitoky
Veteran
Posts: 316
Joined: Sat Feb 07, 2015 9:12 pm
Projects: The Purring Demon's Love, circus eterie
Contact:

Re: Persistent Data in an Extra Story?

#5 Post by mitoky » Fri Feb 08, 2019 10:46 am

Wight wrote:
Thu Feb 07, 2019 7:43 pm
Also, if you haven't already done so, try putting this at the beginning of the Bonus chapter after making the adjustment mitoky suggested:

Code: Select all

$ name = persistent.name
I think the way this works is that the game remembers the persistent flag for the original playthrough's name, and this tells it to copy that flag and set it as the name for the new playthrough in the Bonus chapter. Otherwise it might give an error or fall back on the default name.

Or you can use "[persistent.name]" instead of "[name]" for the dialogue in the Bonus chapter. I'm noticing that works too.
Oh yes, thank you for pointing that out!
DiamondDust132 wrote:
Thu Feb 07, 2019 7:46 pm
Haha! That did it! Thanks a lot to both of you. I was about to tear my hair out there.
And no problem at all (: Dont forget to add [SOLVED] into the title so people know this problem is solved!

Post Reply

Who is online

Users browsing this forum: Google [Bot], strayerror