button "Continue game"

A place for Ren'Py tutorials and reusable Ren'Py code.
Forum rules
Do not post questions here!

This forum is for example code you want to show other people. Ren'Py questions should be asked in the Ren'Py Questions and Announcements forum.
Post Reply
Posts: 108
Joined: Thu Dec 28, 2017 2:37 pm
Location: Russia

button "Continue game"

#1 Post by Andredron » Sun Feb 18, 2018 8:55 am

1) plain

Code: Select all

# action - continue the game from there, where finished
# if there is nothing to upload yet, the button is inactive
# textbutton _ ("Continue game") action Continue ()
init -999 python
    class Continue (Action, DictEquality):
        def __call __ (self):
            FileLoad (1, confirm = False, page = "auto", newest = True) ()
        # clickable button
        def get_sensitive (self):
            return FileLoadable (1, page = "auto")

2) advanced
First, we'll make a record at the very beginning of script.rpy

Code: Select all

label main_menu:
    call screen main_menu
label restart:
    call screen confirm (message = u "Are you sure you want to restart the game?", yes_action = Start (), no_action = Jump ("main_menu"))
### Auto-save activation:
init -1 python hide:
    config.has_autosave = True
Next, we need to go into the script screen, and find there our main menu (I use the standard menu gui) and there add the selected fragments.

Code: Select all

screen navigation ():

        style_prefix "navigation"

        xpos gui.navigation_xpos
        yalign 0.5

        spacing gui.navigation_spacing

        if main_menu:

            textbutton _ ("Start Game") action Jump ("restart")


           textbutton _ ("History") action ShowMenu ("history")

           textbutton _ ("Save") action ShowMenu ("save")

        textbutton _ ("continue") action FileLoad (1, confirm = False, page = "auto", newest = True)
        textbutton _ ("Load game") action ShowMenu ("load")

        textbutton _ ("Options") action ShowMenu ("preferences")
What have we written down here:
When you click on the Start Game button, we call the restart label, which displays the notification screen message (confirm - on new, on old - yesno_prompt) in which you specify whether you want to start a new game.
And by clicking on the Continue game button, we automatically load the last auto save. Thanks to the fact that we registered the activation of autosave, we will load our last place where we stopped.
I know, I have terrible English
I'm writing a Renpy textbook (in Russian). I would be glad if someone translated into an English or German textbook https://yadi.sk/d/ZX_DonP63USRru Update 22.06.18

User avatar
Posts: 473
Joined: Wed Mar 05, 2014 1:00 am
Completed: See my signature
Github: koroshiya
itch: zetsuboushita

Re: button "Continue game"

#2 Post by Zetsubou » Sun Feb 18, 2018 3:38 pm

If you want a button that will continue from your last save of any variety (quick save, normal save, auto save) rather than just auto saves, you can use this instead:

Code: Select all

init +1 python:
    class LoadMostRecent(Action):

        def __init__(self):
            self.slot = renpy.newest_slot()

        def __call__(self):

        def get_sensitive(self):
            return self.slot is not None
Then set the button's action to "LoadMostRecent()".
Finished games
-My games: Sickness, Wander No More, Max Massacre, Humanity Must Perish, Tomboys Need Love Too, Sable's Grimoire
-Commissions: No One But You, Written In The Sky, Diamond Rose, To Libertad, Catch Canvas, Love Ribbon, Happy Campers, Wolf Tails

Working on:
Circadian Loop, My Heart Grows Fonder + VN writing commissions


Post Reply

Who is online

Users browsing this forum: No registered users