Page 1 of 1

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

Posted: Sun May 24, 2020 5:08 pm
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

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

Posted: Sun May 24, 2020 7:52 pm
by Remix
You just want
Function(AutoLoding)

The extra () you had would cause the function to actually run during prediction

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

Posted: Sun May 31, 2020 1:47 pm
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 ;)