Single save file but possible multiple games?

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
inkbrush
Regular
Posts: 60
Joined: Tue Jul 08, 2014 3:28 am
Contact:

Single save file but possible multiple games?

#1 Post by inkbrush »

Hello Lemmasoftians!


I've been looking around the forums and I haven't really found anything on this . . . Soooo, I don't know if it's not possible or if no one has really thought about doing it or if it's actually really simple and I'm just blind.

SO. Here's my question: Is it possible to customize the saving system to have it here there's one save "file" per game? If so, how would I go about coding that?

More information on what I want to do:
I want to have a game where there's a single save file. Kind of like if someone where to just repeatedly save their game on the same slot. It overrides the previous saved file. But you can have multiple games/characters. The story is a single-route dating sim with a customize-able heroine. So, essentially what I want to do is have it where you can have multiple games with different characters but if you want to redo a part of the story to get a different result, you have to replay that specific chapter and you can't just save your progress and re-load it if you choose a wrong option.

So, is this even possible with Ren'Py?


Thank you for any responses ahead of time!

User avatar
Kia
Eileen-Class Veteran
Posts: 1040
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Discord: Kia#6810
Contact:

Re: Single save file but possible multiple games?

#2 Post by Kia »

yes, though it's not a good Idea to force players to use only one save slot. I for example like to have separate saves for every two steps of my game. but it's your game ^_^
open your screens.rpy and go to save/load

Code: Select all

screen file_picker():
-----------------------------------------------------------  remove from here
    frame:
        style "file_picker_frame"

        has vbox

        # The buttons at the top allow the user to pick a
        # page of files.
        hbox:
            style_group "file_picker_nav"

            textbutton _("Previous"):
                action FilePagePrevious()

            textbutton _("Auto"):
                action FilePage("auto")

            textbutton _("Quick"):
                action FilePage("quick")

            for i in range(1, 9):
                textbutton str(i):
                    action FilePage(i)

            textbutton _("Next"):
                action FilePageNext()
-----------------------------------------------------------  to here here

        $ columns = 2 <--------------------------set this to 1
        $ rows = 5     <--------------------------set this to 1 too

        # Display a grid of file slots.
        grid columns rows:
            transpose True
            xfill True
            style_group "file_picker"

            # Display ten file slots, numbered 1 - 10.
            for i in range(1, columns * rows + 1):

                # Each file slot is a button.
                button:
                    action FileAction(i)
                    xfill True

                    has hbox

                    # Add the screenshot.
                    add FileScreenshot(i)

                    $ file_name = FileSlotName(i, columns * rows)
                    $ file_time = FileTime(i, empty=_("Empty Slot."))
                    $ save_name = FileSaveName(i)

                    text "[file_name]. [file_time!t]\n[save_name!t]"

                    key "save_delete" action FileDelete(i)

User avatar
inkbrush
Regular
Posts: 60
Joined: Tue Jul 08, 2014 3:28 am
Contact:

Re: Single save file but possible multiple games?

#3 Post by inkbrush »

Awesome, thank you!

So, I put in the code and it looks good! I'm just wondering if there's a way to make it where there's multiple files, but only one per game. Like, for example, only one save file for a "new game". But having multiple files so a player might be able to have different characters and are pursuing a different love interest than in another file they have.

Also--is there a way to have an autosave function where a player's game is autosaved at certain points? i.e. after they make their character, after a choice, etc. I think someone had a similar idea and was trying to do it over here but they didn't get an answer on their question.

I feel like an autosave function would work a lot better for my game so players don't have to go back and continuously save their game. Because there will be other methods of replaying scenes and such inside the game.

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Single save file but possible multiple games?

#4 Post by trooper6 »

Renpy does have an autosave function already built in.

If you do a search for the term autosave on this page, you'll see all the config.variable that control autosave functions:
http://www.renpy.org/doc/html/config.html

Here is the function that forces an autosave when you want it: http://www.renpy.org/doc/html/other.htm ... e_autosave

Just do some searching in the documentation and you'll find a bit on autosaves
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

User avatar
inkbrush
Regular
Posts: 60
Joined: Tue Jul 08, 2014 3:28 am
Contact:

Re: Single save file but possible multiple games?

#5 Post by inkbrush »

Awesome! Thank you! I did a lot of my own research and figured out how it works for the most part. (And yet so many more questions arise :'D)

If I use "config.autosave_frequency" and I make it autosave actually rather frequently . . . I was hoping to include a dress up part into my game. So if I have the frequency being more frequent, would it autosave while a player is clicking through the different clothing options, or would it autosave after you've hit the "save" button and/or exited out of the dress up?

And is it possible to turn off the autosave feature during certain parts in your game, but keep the frequency for the parts that it would be turned on? Or no?

Also--I still haven't gotten an answer on if it's possible to make a single save/autosave file per game created by the player. And if it is, how would I go about making that?


Sorry for the multitude of questions! Everyone has to start somewhere I suppose. I really do appreciate everyone taking the time to send me responses!

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Single save file but possible multiple games?

#6 Post by trooper6 »

I can't really answer most of your questions because I haven't personally messed with saving in my game yet. I basically learn by experimenting/reading/trial & error in the process of working on my game...and I haven't gotten to that part yet! But hopefully someone who knows about that sort of thing can step in.

But I don't think you can change config variables once the game is set. You could make is so that the game doesn't autosave at all by default and then just force the autosave when you want it to.

Also, a for the dressup game question, a button click is an interaction as far as I know, so if you have the frequency set to 200 and the player clicks dress up games buttons 200 times, it would trigger an autosave.

As for having only one autosave slot...I'd do a search of the questions thread...that one I'm sure someone has asked already.

Anyway, I hope someone experienced with this part of renpy steps in to help!
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

User avatar
Kia
Eileen-Class Veteran
Posts: 1040
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Discord: Kia#6810
Contact:

Re: Single save file but possible multiple games?

#7 Post by Kia »

inkbrush wrote:Also--I still haven't gotten an answer on if it's possible to make a single save/autosave file per game created by the player. And if it is, how would I go about making that?
yes it's doable,
try defining a variable for the character number and match the same slot to that.

Code: Select all

-------------------somewhere in the scriopt
define charnumber = 1
-------------------somewhere after character 2 starts
$ charnumber = 2
-------------------- and the same for another characters

------------------------------------- you can get ride of this part too
        grid columns rows:
            transpose True
            xfill True
            style_group "file_picker"

            # Display ten file slots, numbered 1 - 10.
            for i in range(1, columns * rows + 1):
-------------------------------------------------------------------------- to here, when you have a variable named "charnumber" for example you can insert it anywhere you see the "i" variable.
                # Each file slot is a button.
                button:
                    action FileAction(i) <---------- here
                    xfill True

                    has hbox

                    # Add the screenshot.
                    add FileScreenshot(i) <---------- here

                    $ file_name = FileSlotName(i, columns * rows) <---------- here
                    $ file_time = FileTime(i, empty=_("Empty Slot.")) <---------- here
                    $ save_name = FileSaveName(i) <---------- here

                    text "[file_name]. [file_time!t]\n[save_name!t]"

                    key "save_delete" action FileDelete(i) <---------- here
you will have some problem and mistakes but don't worry we are here to help you trough.

User avatar
inkbrush
Regular
Posts: 60
Joined: Tue Jul 08, 2014 3:28 am
Contact:

Re: Single save file but possible multiple games?

#8 Post by inkbrush »

Code: Select all

-------------------somewhere in the scriopt
define charnumber = 1
-------------------somewhere after character 2 starts
$ charnumber = 2
-------------------- and the same for another characters
I'm a little confused on how/where I would put this code in. Could you elaborate a little further, please? And do I have to add code in for the game to recognize how many characters are saved already?? . . . I don't feel like I explained that very well. For example:


When starting a new game, you're prompted to enter your character's name and then you're taken to the customization screen where you can choose a hairstyle, hair color, eye color, skin color, etc. and then there will be an autosave when you're done with that.

So, you've got your first character. But then you want to go after another love interest in another game. So you make a new game and there's the same process. That's your second character.

And so on . . . But what if you delete your first saved character?? Will it automatically update that second character to being the first?


Also--
you will have some problem and mistakes but don't worry we are here to help you trough.
Seeing that made me so relieved. Thank you to both of you!!

User avatar
Kia
Eileen-Class Veteran
Posts: 1040
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Discord: Kia#6810
Contact:

Re: Single save file but possible multiple games?

#9 Post by Kia »

you need to give each of your characters a unique number. they will live by that number their whole life no matter what happens to others.
you need to define your variables early (before the start label for example)
you can assign a number to the character when they are created (I guess after entering the name is a good time)
for choosing from your created characters you need yet another screen and here is when the code gets complicated the most, if you are planing to hire a programmer for your game now is good time.
start writing your code till you encounter a problem so we have something to look at.

Post Reply

Who is online

Users browsing this forum: Semrush [Bot]