Ren'Py Change name rollbackproof/ variable store question

Playstorepers

Member
May 24, 2020
160
79
Hey guys,

I have a "Menu" screen (think of it as a phone, a character app to be precise), which has a name change option.

It works okayish and does its job, but if for whatever reason the player decides to rollback to a point, before the name change, the name change becomes reverted (Makes sense, I guess).
Is there a way to store the name variable rollbackproof?
I can't use the persistent, since it would store the name for EVERY save state and i dont want to disallow the rollback, because that's kinda a dick move.

I'm sure there must be a way.

Thanks in advance.



my code rn:

Python:
screen enternamechange:

    modal True

    tag menu

    add "images/background/datapage.png"

    frame:

        area(650, 380, 620, 320)

    vbox:

        xalign 0.5

        yalign 0.5

        spacing 40

        text "What is your first name?": 

            size 36


        input default name:

            size 40

            xalign 0.5

            pixel_width(430)#stops too long names

            value VariableInputValue("name")


        textbutton "Confirm":

            xalign 0.5

            action (Notify("The first name was changed."), ShowMenu("character_app"))
As mentioned above it works fine, but a rollback kicks it right into its nuts.

Thanks in advance again
 
Last edited:

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,581
2,219
To ask the obvious question... why do you want the name to be kept beyond the rollback?

I mean... that's kinda the whole point to rollback... the player goes back to a point before something happened. If the player rolls back to a point before the name was entered... then the name the player entered is forgotten... because that is what the player effectively asked the game to do. It's standard RenPy behavior and therefore not something that should surprise anyone.

But to answer your question, with a possible solution...

After the game has accepted the new name, store a copy of it as a separate persistent variable.
If that persistent variable exists when the player invokes the name entry screen - use that persistent name as the default name.

That way, first time through... the player will deal with the naming screen normally (since the persistent variable won't exist).
But if they rollback and go through it again, the "new" name will appear for them.
Or some sort of variation on that theme.
You may need a 3rd variable for the "default name to be used"... but since you're already doing complex things, that shouldn't be too much of a stretch to figure out.
 
  • Like
Reactions: Playstorepers

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,359
15,270
Is there a way to store the name variable rollbackproof?
No, and 79flavors explained why it shouldn't be done anyway.

But, if really you want to prevent the player to change the name (what some will hate and what will make them simply forget about your game), you can just tell Ren'py to not rollback to this point with .
 
  • Like
Reactions: Playstorepers

Playstorepers

Member
May 24, 2020
160
79
Thanks for the quick answers and thanks for the small workaround, I guess.

I won't cut off the rollback as mentioned in OP-post.

It just occured to me, that if a player changes their name and then want to read stuff again (without the backlog, but with a rollback), the name change would disappear, but it seems like the workarounds are really suboptimal.

I'll probably just add a warning, that rollbacks delete the name change and be done with it.

Thanks again, everyone.