What would be a way to "save game" on this case?

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
Nanahs
Veteran
Posts: 297
Joined: Wed Aug 22, 2018 5:50 pm
Contact:

What would be a way to "save game" on this case?

#1 Post by Nanahs » Sun Feb 24, 2019 2:41 pm

I've been working in a game that is like a cellphone. It's not a professional game. It's more like, just for fun. So there's no need to be "perfect" or anything.

It's a 720x1280 game, and it's something like this:

Image

Instead of the game starting at the that screen with the "start, load, preferences, etc" I wanted the game to start directly at the "phone menu" label (the image above). After the person plays it for the first time.

So I'm using this:

Code: Select all

init python:
    config.has_autosave = True
    config.autosave_slots = 1
    config.autosave_on_choice = True
    config.autosave_on_quit = True
    
define config.auto_load = renpy.newest_slot(regexp="auto") 
After you play the game for the first time and closes it at the phone menu, it always reload from there.

The problem is that the game saves only till this part.
The player can change their name and customize other things at "configuration", but the game doesn't save it automatically.

I tried adding:

Code: Select all

    $autosave_slots = 1
But I think I doesn't work.

The game actually works great this way for a few hours.
But when you play it, like, in the next day, it goes back to the beginning. To the start labels where you put your name, etc.

Does anyone know if there's a way I can fix that?

To make it short: I wanted the game to always autosave everything (to remember the custom names, etc) and start at "label phonemenu".

Thanks.

User avatar
xavimat
Eileen-Class Veteran
Posts: 1446
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love, unknown
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Contact:

Re: What would be a way to "save game" on this case?

#2 Post by xavimat » Tue Feb 26, 2019 2:44 pm

Saving of variables depends on several things.
If you initialize a variable in an "init python" block, it's possible that renpy won't save it in the saves.
You should always initialize your variables with "default", so renpy knows that those variables must be saved.
Also, it depends how are you changing those variables in your "configuration".
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

User avatar
xavimat
Eileen-Class Veteran
Posts: 1446
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love, unknown
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Contact:

Re: What would be a way to "save game" on this case?

#3 Post by xavimat » Wed Feb 27, 2019 2:21 pm

(sorry for double post)

I was trying a solution when I realized that, without knowing how variables are handled, it was not possible to know for sure if my solution will work.
Anyway, you can try this:

Code: Select all

define persistent.started = False
default _quit_slot = "mysave"

label before_main_menu:
    if persistent.started:
        $ renpy.load("mysave")
    return

label start:
    $ persistent.started = True
    "bla1"
    "bla2"
    "bla3"
    "bla4"
    "bla5"
    "bla6"
    "bla7"
    "bla8"
    "bla9"
    jump start
- Do you want to avoid the user going to the main menu ever again, for ever and ever?
Then delete the button in the "screen navigation():" (file: screens.rpy) that goes to the Main Menu.
- Will your player be able to go to the main menu? Then the persistent variable needs to be set to False again. Change that same "Main Menu" button this way:

Code: Select all

textbutton _("Main Menu") action [SetVariable("persistent.started", False), MainMenu()]
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

User avatar
Nanahs
Veteran
Posts: 297
Joined: Wed Aug 22, 2018 5:50 pm
Contact:

Re: What would be a way to "save game" on this case?

#4 Post by Nanahs » Thu Feb 28, 2019 7:47 pm

xavimat wrote:
Wed Feb 27, 2019 2:21 pm
(sorry for double post)

I was trying a solution when I realized that, without knowing how variables are handled, it was not possible to know for sure if my solution will work.
Anyway, you can try this:

Code: Select all

define persistent.started = False
default _quit_slot = "mysave"

label before_main_menu:
    if persistent.started:
        $ renpy.load("mysave")
    return

label start:
    $ persistent.started = True
    "bla1"
    "bla2"
    "bla3"
    "bla4"
    "bla5"
    "bla6"
    "bla7"
    "bla8"
    "bla9"
    jump start
- Do you want to avoid the user going to the main menu ever again, for ever and ever?
Then delete the button in the "screen navigation():" (file: screens.rpy) that goes to the Main Menu.
- Will your player be able to go to the main menu? Then the persistent variable needs to be set to False again. Change that same "Main Menu" button this way:

Code: Select all

textbutton _("Main Menu") action [SetVariable("persistent.started", False), MainMenu()]
Thank you so much! I'll try that :)

Post Reply

Who is online

Users browsing this forum: DsyD, Google [Bot]