[Solved] One SaveGame system - how to load and run 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
JeffSevenDee
Newbie
Posts: 7
Joined: Fri Apr 10, 2020 2:46 pm
Projects: Coding my wife's project
Contact:

[Solved] One SaveGame system - how to load and run savegame

#1 Post by JeffSevenDee »

I try to have a main menu as simple as possible :
A New Game button when no save game is detected, a Run Game when one is of course available and a Quit button.
Given that there is only one savegame in scope, I do not want to have to deal with the usual loader.

So my navigation menu looks like thius:

Code: Select all

screen navigation():

    vbox:
        style_prefix "navigation"

        xpos gui.navigation_xpos
        yalign 0.5

        spacing gui.navigation_spacing

        #if main_menu:
        if not savegame_present:
            textbutton _("New Game") action Start()
        else:
            textbutton _("Auto Load") action Function(AutoLoding())

        if renpy.variant("pc"):

            ## The quit button is banned on iOS and unnecessary on Android and
            ## Web.
            textbutton _("Quit") action Quit(confirm=not main_menu)
Here is the function's definition:

Code: Select all

    def AutoLoding():
        return renpy.load( "1-1" )
And here is how I know the game exists

Code: Select all

label main_menu:
    $ savegame_present = renpy.can_load("1-1", True)
    call screen main_menu
    return
What I found puzzling is that upon launching the program, the code breaks while loading the game, even before the menu appears.
So it seems there is an evaluation done to see if the menu item will be disabled. Am I right ?
If so... is there a way to tell renpy to enable the menu and not do a pre-evaluation ?
And.. is it a viable way to get the feature done ?
Thanks in advance for all the help
Last edited by JeffSevenDee on Sun May 31, 2020 1:51 pm, edited 1 time 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: One SaveGame system - how to load and run savegame

#2 Post by Remix »

You just want
Function(AutoLoding)

The extra () you had would cause the function to actually run during prediction
Frameworks & Scriptlets:

JeffSevenDee
Newbie
Posts: 7
Joined: Fri Apr 10, 2020 2:46 pm
Projects: Coding my wife's project
Contact:

[Solved] Re: One SaveGame system - how to load and run savegame

#3 Post by JeffSevenDee »

it worked perfectly!
Thanks a lot sir :D
After your answer, I searched the Documentatio and found out what you are refering to. Another brick in the wall ;)

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot]