How do I disable saves from old versions?

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
Wiceramond
Regular
Posts: 25
Joined: Mon Dec 07, 2020 8:40 am
Contact:

How do I disable saves from old versions?

#1 Post by Wiceramond »

I want to disable old save files for loading based on the game's version. I have defined the config.version in every version. So let's say my game's latest version is 2.6 and I want to disable saves from 2.5 2.4 2.3 etc. Is it possible? And if it's possible, how?

User avatar
hell_oh_world
Miko-Class Veteran
Posts: 777
Joined: Fri Jul 12, 2019 5:21 am
Contact:

Re: How do I disable saves from old versions?

#2 Post by hell_oh_world »

pretty much yeah. you can try this...
create a list of versions that are compatible with the current build. The versions in this list must be a valid version, a version that you once put in the `config.version` inside `options.rpy`

Code: Select all

define _compatible_versions = (
  "2.5", "2.6", "2.7", # assume that 2.7 here is your current build's `config.version`, and the minimum playable save version is 2.5
)
then on line 676 of screens.rpy (inside screen file_slots), add a sensitive property for the button

Code: Select all

button:
  action FileAction(slot)
  sensitive (FileJson(slot, "_version") in _compatible_versions) # by default config.version is already stored in your save as _version, so we will fetch that and compare if that version is compatible.

User avatar
Wiceramond
Regular
Posts: 25
Joined: Mon Dec 07, 2020 8:40 am
Contact:

Re: How do I disable saves from old versions?

#3 Post by Wiceramond »

hell_oh_world wrote: Sun Feb 28, 2021 9:40 am pretty much yeah. you can try this...
create a list of versions that are compatible with the current build. The versions in this list must be a valid version, a version that you once put in the `config.version` inside `options.rpy`

Code: Select all

define _compatible_versions = (
  "2.5", "2.6", "2.7", # assume that 2.7 here is your current build's `config.version`, and the minimum playable save version is 2.5
)
then on line 676 of screens.rpy (inside screen file_slots), add a sensitive property for the button

Code: Select all

button:
  action FileAction(slot)
  sensitive (FileJson(slot, "_version") in _compatible_versions) # by default config.version is already stored in your save as _version, so we will fetch that and compare if that version is compatible.
Thanks a lot, it's almost working for me, but I can't save anything at all, quick save works fine, not by clicking on the empty slot tho. Basically I can't click on any empty slots.

User avatar
hell_oh_world
Miko-Class Veteran
Posts: 777
Joined: Fri Jul 12, 2019 5:21 am
Contact:

Re: How do I disable saves from old versions?

#4 Post by hell_oh_world »

right. sorry. try this.

Code: Select all

sensitive (FileJson(slot, "_version", missing=config.version) in _compatible_versions)

User avatar
Wiceramond
Regular
Posts: 25
Joined: Mon Dec 07, 2020 8:40 am
Contact:

Re: How do I disable saves from old versions?

#5 Post by Wiceramond »

hell_oh_world wrote: Sun Feb 28, 2021 10:13 am right. sorry. try this.

Code: Select all

sensitive (FileJson(slot, "_version", missing=config.version) in _compatible_versions)
Oh, I'm really sorry. Tried that one but it's just the same. Also, even if it works players won't be able to overwrite old saves I guess. That's okay but can I use grayscale on disabled saves' images?

User avatar
hell_oh_world
Miko-Class Veteran
Posts: 777
Joined: Fri Jul 12, 2019 5:21 am
Contact:

Re: How do I disable saves from old versions?

#6 Post by hell_oh_world »

Right, so sorry again, i missed one more parameter in that code, so it should look like this now.

Code: Select all

sensitive (FileJson(slot, "_version", config.version, config.version) in _compatible_versions)
also, modify the compatible versions to be like this (observe that we're using {} instead of []).

Code: Select all

define _compatible_versions = {
  "old_config_version_1", "old_config_version_2", config.version # ensure that your current game's version is included in the compatible versions.
}
That's okay but can I use grayscale on disabled saves' images?
Ren'Py 7.4 should allow you to do this, so be sure you're using the latest version of renpy.

Code: Select all

                    # moved above the button
                    $ compatible = (FileJson(slot, "_version", config.version, config.version) in _compatible_versions)
                    
                    button:
                        action FileAction(slot)
                        
                        sensitive compatible

                        has vbox
                        
                        # change your screenshot to this...
                        add FileScreenshot(slot):
                          xalign 0.5
                          
                          if not compatible:
                            at transform:
                              matrixcolor SaturationMatrix(0.0)
Also, even if it works players won't be able to overwrite old saves I guess.
Correct. to do that, you need to modify the condition a bit.

Code: Select all

                    # moved above the button
                    $ compatible = (FileJson(slot, "_version", config.version, config.version) in _compatible_versions)
                    $ compatible = compatible if renpy.get_screen("load") else True
                    
                    button:
                        action FileAction(slot)

User avatar
Wiceramond
Regular
Posts: 25
Joined: Mon Dec 07, 2020 8:40 am
Contact:

Re: How do I disable saves from old versions?

#7 Post by Wiceramond »

hell_oh_world wrote: Sun Feb 28, 2021 11:03 am Right, so sorry again, i missed one more parameter in that code, so it should look like this now.

Code: Select all

sensitive (FileJson(slot, "_version", config.version, config.version) in _compatible_versions)
also, modify the compatible versions to be like this (observe that we're using {} instead of []).

Code: Select all

define _compatible_versions = {
  "old_config_version_1", "old_config_version_2", config.version # ensure that your current game's version is included in the compatible versions.
}
That's okay but can I use grayscale on disabled saves' images?
Ren'Py 7.4 should allow you to do this, so be sure you're using the latest version of renpy.

Code: Select all

                    # moved above the button
                    $ compatible = (FileJson(slot, "_version", config.version, config.version) in _compatible_versions)
                    
                    button:
                        action FileAction(slot)
                        
                        sensitive compatible

                        has vbox
                        
                        # change your screenshot to this...
                        add FileScreenshot(slot):
                          xalign 0.5
                          
                          if not compatible:
                            at transform:
                              matrixcolor SaturationMatrix(0.0)
Also, even if it works players won't be able to overwrite old saves I guess.
Correct. to do that, you need to modify the condition a bit.

Code: Select all

                    # moved above the button
                    $ compatible = (FileJson(slot, "_version", config.version, config.version) in _compatible_versions)
                    $ compatible = compatible if renpy.get_screen("load") else True
                    
                    button:
                        action FileAction(slot)
Thanks a lot, it's working now. You saved me there.

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

Re: How do I disable saves from old versions?

#8 Post by Imperf3kt »

I'm curious why you're interested in such a feature. I can't think of any reason why you would want this feature other than trying to fix loading errors from improperly defined variables.
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

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Majestic-12 [Bot], Semrush [Bot]