Single Save/Load File? [SOLVED]

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
CSV
Regular
Posts: 145
Joined: Sun Aug 31, 2014 6:58 pm
Tumblr: csvidaldraws
Deviantart: csvidal
itch: csvidal
Location: Portugal
Contact:

Single Save/Load File? [SOLVED]

#1 Post by CSV »

I am using "one-screen mode" and I would like to include a simple save/load function based on a single save file. I have searched the forums but I can't seem to find the right code for this.

Code: Select all

# The game starts here.
label start:
           
    scene black
    N "GAME TITLE"
    menu:
        "start":
            jump begin
            
        "load" ##### Clicking this option should load the game's single save file if it exists.
                 #####I also need to add a permanent "save" button after the game story starts.

Thank you in advance. :)
Last edited by CSV on Fri Sep 15, 2017 5:20 pm, edited 1 time in total.
☆☆☆
(portfolio)
☆☆☆☆☆☆☆☆☆

User avatar
Divona
Miko-Class Veteran
Posts: 678
Joined: Sun Jun 05, 2016 8:29 pm
Completed: The Falconers: Moonlight
Organization: Bionic Penguin
itch: bionicpenguin
Contact:

Re: Single Save/Load File?

#2 Post by Divona »

FileSave() and FileLoad() should do the job. Alternatively, you can use renpy.save() and renpy.load().

Code: Select all

# The game starts here.
label start:
           
    scene black
    N "GAME TITLE"
    menu:
        "start":
            jump begin
            
        "save":
            $ FileSave(1, confirm=False)()

        "load":
            $ FileLoad(1, confirm=False)()
            "Save file does not exist."
            jump start
Completed:
Image

User avatar
CSV
Regular
Posts: 145
Joined: Sun Aug 31, 2014 6:58 pm
Tumblr: csvidaldraws
Deviantart: csvidal
itch: csvidal
Location: Portugal
Contact:

Re: Single Save/Load File?

#3 Post by CSV »

Divona wrote: Sun Sep 10, 2017 12:33 am FileSave() and FileLoad() should do the job. Alternatively, you can use renpy.save() and renpy.load().

Code: Select all

# The game starts here.
label start:
           
    scene black
    N "GAME TITLE"
    menu:
        "start":
            jump begin
            
        "save":
            $ FileSave(1, confirm=False)()

        "load":
            $ FileLoad(1, confirm=False)()
            "Save file does not exist."
            jump start
Thank you! This worked for the load button, but I still can't figure out how to have a "save" button always present during the game. :?
☆☆☆
(portfolio)
☆☆☆☆☆☆☆☆☆

User avatar
Divona
Miko-Class Veteran
Posts: 678
Joined: Sun Jun 05, 2016 8:29 pm
Completed: The Falconers: Moonlight
Organization: Bionic Penguin
itch: bionicpenguin
Contact:

Re: Single Save/Load File?

#4 Post by Divona »

To have "save" button always present during the game, you will have to create a screen and show it at the start.

Code: Select all

screen save_button():
    frame:
        pos (10, 10)
        textbutton "Save" action FileSave(1)

label start:
    show screen save_button

    scene black
    N "GAME TITLE"

    . . .
Completed:
Image

Post Reply

Who is online

Users browsing this forum: Bing [Bot]