Managing save slots

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
Razka
Newbie
Posts: 12
Joined: Wed Jan 01, 2020 10:58 pm
Projects: Testament Legacy - Ch.1
Contact:

Managing save slots

#1 Post by Razka »

I'm trying to manage a game with two difficulties, one with many save slots and the other with just one save.
To avoid messing with the player saves, I wanted to use 2 page sets: If the difficulty is hard, then you only see one page (let's say page 99) and that page only has 1 save slot. The other set, a normal set with 3 pages.

First problem: when you launch the game, the "Load" screen doesn't recognize the difficulty variable. I tried making it persistent, like this:

Code: Select all

default persistent.hardcoreMode = False
(and obviously it gets assigned at the start of the game) but when you click load and check it:

Code: Select all

if not hardcoreMode:
                    for page in range(1, 4):
                        textbutton "[page]" action FilePage(page)
                else:
                    for page in range(99, 100):
                        textbutton "Hard Save Slot" action FilePage(page)
the game crashes with "name hardcoremode not defined".

Second: no matter how well I can manage the different sets of saved games pages, whenever you open "save" or "load" screen it lands on the last page opened. So if you save a standard game, then launch an hardcore game, you'll see the page you saved earlier even if you're not supposed to.
There should be some kind of event to force the page to load on the first one and not the last one used, but alas, I wasn't able to find it.

User avatar
RicharDann
Veteran
Posts: 286
Joined: Thu Aug 31, 2017 11:47 am
Contact:

Re: Managing save slots

#2 Post by RicharDann »

For the first problem, when using or checking the value of persistent variables, you need to include persistent before their name:

Code: Select all

if not persistent.hardcoreMode:
    # show save pages

For the second problem, you could use 'on show' statement to force the game to show a particular page (unsure if this will work as I'm not able to test now):

Code: Select all

on 'show':
    if persistent.hardcoreMode:
        action FilePage(99)
The most important step is always the next one.

Post Reply

Who is online

Users browsing this forum: Google [Bot]