deleting all persistent data except the persistent on the savegame

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
Mjhay
Regular
Posts: 61
Joined: Sat Jan 16, 2021 2:29 pm
Location: Philippines
Contact:

deleting all persistent data except the persistent on the savegame

#1 Post by Mjhay »

my new game button on main menu is working, but my problem is when i create new game, the persistent data the on the save game is also deleted.

and i want that if i create new game all the persistent data will be deleted except the persistent data on the save game. or should i say when create new game, the game will restart like you back to zero but save game should not be deleted. sorry for the bad english :(

for short, i want to make multiple user.
hope someone understand my thought
and thanks for the help. :)

this is the code on screen rpy:

Code: Select all

init python:
  def newGame(*args, **kwargs):
    persistent._clear(True)             ####is there a function that i could use on this? ####
    renpy.run(Start(*args, **kwargs))

  def NewGame(*args, **kwargs): return Function(newGame, *args, **kwargs)

  def NewGame(confirm=True, message=_("Do you want to create New Game.{p}Do you want to continue?")):
    action = Function(newGame)

    if confirm:
      action = Confirm(message, action)

    return action
    
screen main_menu():

    ## This ensures that any other menu screen is replaced.
    tag menu
    
    style_prefix "main_menu"

    add gui.main_menu_background

    ## menu buttons code here

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

Re: deleting all persistent data except the persistent on the savegame

#2 Post by Ocelot »

There is no persistent data in the save game. The whole point of persistent data is to exist outside of saves and game instances, to persist even when you start a new game or delete a save. It is shared data belonging to application itself. If you want some data to be part of saved game, you should not store it in the persistent data.
< < insert Rick Cook quote here > >

User avatar
Mjhay
Regular
Posts: 61
Joined: Sat Jan 16, 2021 2:29 pm
Location: Philippines
Contact:

Re: deleting all persistent data except the persistent on the savegame

#3 Post by Mjhay »

Ocelot wrote: Wed May 05, 2021 10:30 am There is no persistent data in the save game. The whole point of persistent data is to exist outside of saves and game instances, to persist even when you start a new game or delete a save. It is shared data belonging to application itself. If you want some data to be part of saved game, you should not store it in the persistent data.
oh no ! :o
so what should i do?

User avatar
Mjhay
Regular
Posts: 61
Joined: Sat Jan 16, 2021 2:29 pm
Location: Philippines
Contact:

Re: deleting all persistent data except the persistent on the savegame

#4 Post by Mjhay »

Ocelot wrote: Wed May 05, 2021 10:30 am There is no persistent data in the save game. The whole point of persistent data is to exist outside of saves and game instances, to persist even when you start a new game or delete a save. It is shared data belonging to application itself. If you want some data to be part of saved game, you should not store it in the persistent data.
and so, renpy can't create a multiple user? on for single user is that right?
because how can i create new game if the persistent on the other save game will lost. so the save game will be ruin. :roll:

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

Re: deleting all persistent data except the persistent on the savegame

#5 Post by Ocelot »

If something is needed for the game itself, it should not be stored in persistent data. Persistent data is for something which remains and can be accessed even in other saves/new games or in the main menu itself. Like unlocked CGs, completed routes, unlocked chapters or something like that.
Deleting persistent data on new game is very sketchy and is probably means that there is something that should not be stored in persistent data at all.
Mjhay wrote: Wed May 05, 2021 10:53 am and so, renpy can't create a multiple user? on for single user is that right?
I am not quite sure what do you mean by multiple users. If it is something like different profiles, I usually let OS do that. If you want, you can implement different user profiles with their own save directory, own completition data and so on, and store them in persistent data, but again, there would be no need to clear persistent data. At most, you will delete profile entry.
< < insert Rick Cook quote here > >

User avatar
Mjhay
Regular
Posts: 61
Joined: Sat Jan 16, 2021 2:29 pm
Location: Philippines
Contact:

Re: deleting all persistent data except the persistent on the savegame

#6 Post by Mjhay »

Ocelot wrote: Wed May 05, 2021 11:03 am I am not quite sure what do you mean by multiple users. If it is something like different profiles, I usually let OS do that. If you want, you can implement different user profiles with their own save directory, own completition data and so on, and store them in persistent data, but again, there would be no need to clear persistent data. At most, you will delete profile entry.
ahh is that so.
how can i do that ?
can you give me example to start with. ?

User avatar
emz911
Regular
Posts: 103
Joined: Fri Jun 23, 2017 2:23 pm
Contact:

Re: deleting all persistent data except the persistent on the savegame

#7 Post by emz911 »

Data for a specific save will not be deleted if you start a new game. If you save a progress, you can start a new game and load the old save anytime you want, you will not lose any progress. I think what you want is just basic variables function, not persistent. Define them as default or in your start label:

Code: Select all

label start:
     $ money = 0
     $ anything = 0
Throughout gameplay, adjust these variables:

Code: Select all

$ money += 100
“I now have [money] dollars.”
Go to your save/load screen, save this in a save slot, return to the main menu and create a new game. The new game will start off with 0 money. When you want to access the other saved game, go to the save/load screen again and load it, the money variable has not changed, it is 100, because saving and loading will not be influenced between saves.
I’m not sure if this is what you are looking for, but if you only want data that is unique to different saves, don’t use persistent.

User avatar
Mjhay
Regular
Posts: 61
Joined: Sat Jan 16, 2021 2:29 pm
Location: Philippines
Contact:

Re: deleting all persistent data except the persistent on the savegame

#8 Post by Mjhay »

emz911 wrote: Wed May 05, 2021 1:14 pm Data for a specific save will not be deleted if you start a new game. If you save a progress, you can start a new game and load the old save anytime you want, you will not lose any progress. I think what you want is just basic variables function, not persistent. Define them as default or in your start label:

Code: Select all

label start:
     $ money = 0
     $ anything = 0
Throughout gameplay, adjust these variables:

Code: Select all

$ money += 100
“I now have [money] dollars.”
Go to your save/load screen, save this in a save slot, return to the main menu and create a new game. The new game will start off with 0 money. When you want to access the other saved game, go to the save/load screen again and load it, the money variable has not changed, it is 100, because saving and loading will not be influenced between saves.
I’m not sure if this is what you are looking for, but if you only want data that is unique to different saves, don’t use persistent.
yeah ur right, thats it but what about my unlocked chapter and secret routes or label and my achievement? i use persistent on that .
it has any other way to make that except persistent?

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3785
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: deleting all persistent data except the persistent on the savegame

#9 Post by Imperf3kt »

If you want multiple players that is usually handled by the operating system, but you can do it yourself by creating some sort of profile I guess.

I don't know how you'd do it, but you'd likely want a system in place where players create a profile, "log in" as said profile, and then all persistent data is attributed to persistent.profile.variable
The save data would likely have to be treated the same way.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

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

Re: deleting all persistent data except the persistent on the savegame

#10 Post by m_from_space »

Mjhay wrote: Wed May 05, 2021 10:21 pm yeah ur right, thats it but what about my unlocked chapter and secret routes or label and my achievement? i use persistent on that .
it has any other way to make that except persistent?
Maybe somebody should just tell you that renpy automatically saves every variable that is defined and changed within your code when saving it via the built-in save slots.
So all you need to do for e.g. unlocking chapters and saving their state is ... having a variable that keeps track of it. The easiest way would be:

Code: Select all

# create a variable that stores if the chapter is unlocked, by default it is False
default secret_route = False

label start:
	...
	# somewhere within the game
	$ secret_route = True
Renpy will automatically save the variable "secret_route" if you save the game in a slot and it has changed to "True". If it was not changed to "True", it will just load the variable on the next time you load the game and set it to "False", as expected.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]