How can I disable the "Load" button when there are no existing save files?

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
janeyney
Newbie
Posts: 4
Joined: Fri Feb 15, 2019 8:40 am
Contact:

How can I disable the "Load" button when there are no existing save files?

#1 Post by janeyney »

I want the player to be unable to access the Load menu if they don't have a save file yet.


I've managed to find this topic but it only works for one save / Quicksave files.

So far I've managed to do it but it only detects save files for the 1st slot on Page 1 and for the 1st slot on the Quicksave page. I'm just not sure if this is enough...

Code: Select all

 if renpy.can_load("1-1", "quick-1"):
            textbutton _("LOAD") action ShowMenu("load")
        else:
            textbutton _("LOAD")
On an additional note, I'd also like to know if there's a way for Ren'py to automatically tell if there's an existing save file on the Quicksave page AND on any page number.

* I'm a newbie so please bear with me! :oops: Thanks in advance!

UPDATE: I took Remix's advice and it worked!

Code: Select all

        if renpy.list_saved_games(fast=True):
            textbutton _("Load") action ShowMenu("load")
        else:
            textbutton _("Load")
BUT when I try to delete the save and reload the game (to test it out), the Load button remains acessible :?
Last edited by janeyney on Tue Feb 26, 2019 12:55 pm, edited 2 times in total.

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: How can I disable the "Load" button when there are no existing save files?

#2 Post by Remix »

if renpy.list_saved_games(): ## at least one save or auto-save has happened
Frameworks & Scriptlets:

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

Re: How can I disable the "Load" button when there are no existing save files?

#3 Post by Imperf3kt »

I'd use Remix's suggestion in conjunction with SensitiveIf
https://www.renpy.org/doc/html/screen_a ... ensitiveIf

That way, the button still shows, but cannot be clicked until at least one save file exists.
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

janeyney
Newbie
Posts: 4
Joined: Fri Feb 15, 2019 8:40 am
Contact:

Re: How can I disable the "Load" button when there are no existing save files?

#4 Post by janeyney »

Remix wrote: Fri Feb 15, 2019 10:47 am if renpy.list_saved_games(): ## at least one save or auto-save has happened
Hi!

So I tried using this

Code: Select all

 if renpy.list_saved_games(regexp='1', fast=False):
            textbutton _("LOAD") action ShowMenu("load")
        else:
            textbutton _("LOAD")
It disables the Load button but I already have 2 autosaves. It's still also not clear to me how to use the list saved games function(?). Can u please elaborate it a little? Thanks so much!!! :oops:

janeyney
Newbie
Posts: 4
Joined: Fri Feb 15, 2019 8:40 am
Contact:

Re: How can I disable the "Load" button when there are no existing save files?

#5 Post by janeyney »

Imperf3kt wrote: Fri Feb 15, 2019 4:11 pm I'd use Remix's suggestion in conjunction with SensitiveIf
https://www.renpy.org/doc/html/screen_a ... ensitiveIf

That way, the button still shows, but cannot be clicked until at least one save file exists.
Oh, I've never noticed that code before lol. :oops: Thank you!

janeyney
Newbie
Posts: 4
Joined: Fri Feb 15, 2019 8:40 am
Contact:

Re: How can I disable the "Load" button when there are no existing save files?

#6 Post by janeyney »

up! still need help figuring things out! :C

User avatar
xavimat
Eileen-Class Veteran
Posts: 1461
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Discord: xavimat
Contact:

Re: How can I disable the "Load" button when there are no existing save files?

#7 Post by xavimat »

janeyney wrote: Fri Feb 15, 2019 8:59 amUPDATE: I took Remix's advice and it worked!

Code: Select all

        if renpy.list_saved_games(fast=True):
            textbutton _("Load") action ShowMenu("load")
        else:
            textbutton _("Load")
BUT when I try to delete the save and reload the game (to test it out), the Load button remains acessible :?
Renpy saves your game information (persistent stuff and saves) in two locations in your computer: 1.the "save" folder in your game. 2.the "save_directory" in your system (it depends on the system, see: https://renpy.org/doc/html/config.html# ... _directory )
So, when you say "I've deleted the save" probably you have only deleted one of the locations (I'm guessing here, there are different ways to "delete" a save, for example, inside the Save/Load screen or manually deleting the folder). Renpy is smart enough to see the other location and find your saves there.
If you delete manually the saves on both locations, you'll get what you need.
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

Post Reply

Who is online

Users browsing this forum: Bing [Bot]