Limit the Saves (Resident Evil Style)

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
neometalero
Regular
Posts: 198
Joined: Sun Oct 23, 2016 3:51 am
Completed: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Projects: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Deviantart: neometalero
Contact:

Limit the Saves (Resident Evil Style)

#1 Post by neometalero »

I want the player to have to spend an item to be able to save the game. Like in Resident Evil, that you need to spend ink in order to save. Any idea on how I can do that? :|
Working on many weird narrative games at Curse Box Studios
Image
https://www.curseboxstudios.com/

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2406
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Limit the Saves (Resident Evil Style)

#2 Post by Ocelot »

Disable buttons on save screen if certain conditions (like having some variable above zero or having an item in inventory) are not met.
< < insert Rick Cook quote here > >

User avatar
neometalero
Regular
Posts: 198
Joined: Sun Oct 23, 2016 3:51 am
Completed: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Projects: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Deviantart: neometalero
Contact:

Re: Limit the Saves (Resident Evil Style)

#3 Post by neometalero »

How can I disable/enable those screen? Im not finding any usefull post about that.
Working on many weird narrative games at Curse Box Studios
Image
https://www.curseboxstudios.com/

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2406
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Limit the Saves (Resident Evil Style)

#4 Post by Ocelot »

If you are using default GUI, you need to modify file_slots screen and change the save buttons to be something like that:

Code: Select all

button:
    action FileAction(slot)
    # ↑ That part is there by default

    if title == "Save": # reuse sacreen argument to avoid a bunch of python code determining current screen
        sensitive saves_left > 0 # saves_left is your variable where you store amount of saves

    # ↓ keep the rest of default button code below
Ideally, you would replace default save/load screen with separate custom screens, so you can drop current screen check and simplify code.
< < insert Rick Cook quote here > >

User avatar
neometalero
Regular
Posts: 198
Joined: Sun Oct 23, 2016 3:51 am
Completed: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Projects: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Deviantart: neometalero
Contact:

Re: Limit the Saves (Resident Evil Style)

#5 Post by neometalero »

Ocelot wrote: Wed May 10, 2023 4:52 pm If you are using default GUI, you need to modify file_slots screen and change the save buttons to be something like that:

Code: Select all

button:
    action FileAction(slot)
    # ↑ That part is there by default

    if title == "Save": # reuse sacreen argument to avoid a bunch of python code determining current screen
        sensitive saves_left > 0 # saves_left is your variable where you store amount of saves

    # ↓ keep the rest of default button code below
Ideally, you would replace default save/load screen with separate custom screens, so you can drop current screen check and simplify code.
So I would need to modify the section screen file_slots(title): inside the Screens file right?
Working on many weird narrative games at Curse Box Studios
Image
https://www.curseboxstudios.com/

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2406
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Limit the Saves (Resident Evil Style)

#6 Post by Ocelot »

Yes, in particular the save button itself (it is the one within grid in that screen).
< < insert Rick Cook quote here > >

User avatar
neometalero
Regular
Posts: 198
Joined: Sun Oct 23, 2016 3:51 am
Completed: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Projects: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Deviantart: neometalero
Contact:

Re: Limit the Saves (Resident Evil Style)

#7 Post by neometalero »

I tried this

Code: Select all

button:
                        action FileAction(slot)

                        # ↑ That part is there by default

                        if title == "Save": # reuse sacreen argument to avoid a bunch of python code determining current screen
                            sensitive saves_left > 0 # saves_left is your variable where you store amount of saves
                            $saves_left=saves_left-1
But the part that substract 1 from the remaining saves is not working. Any idea whats wrong?
Working on many weird narrative games at Curse Box Studios
Image
https://www.curseboxstudios.com/

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2406
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Limit the Saves (Resident Evil Style)

#8 Post by Ocelot »

You should never have a python code with side effects in screens. It is like screens 101.
I am actually surprised that it doesn't work, because it should work too well and you should quickly get negative saves.

It is possible that you have defined saves_left wrong. It should be something like default saves_left = 0

You will need to use SetVariable action as one of the actions for your button. It should be placed before action that does actual saving, so reduced value would be saved.
As you need to value to decrement only on save, you will have to drop FileAction and instead use either FileSave or FileLoad actions, choosing between them depending on current screen. Something like

Code: Select all

if title == "Save":
     action [SetVariable("saves_left", saves_left - 1), FileSave(slot)]
else:
    action FileLoad(slot)
At this point I highly recommend to drop file_slots screen and design your own, or eventually it will littered with title == "Save" checks.
< < insert Rick Cook quote here > >

User avatar
neometalero
Regular
Posts: 198
Joined: Sun Oct 23, 2016 3:51 am
Completed: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Projects: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Deviantart: neometalero
Contact:

Re: Limit the Saves (Resident Evil Style)

#9 Post by neometalero »

Ocelot wrote: Wed May 10, 2023 6:07 pm You should never have a python code with side effects in screens. It is like screens 101.
I am actually surprised that it doesn't work, because it should work too well and you should quickly get negative saves.

It is possible that you have defined saves_left wrong. It should be something like default saves_left = 0

You will need to use SetVariable action as one of the actions for your button. It should be placed before action that does actual saving, so reduced value would be saved.
As you need to value to decrement only on save, you will have to drop FileAction and instead use either FileSave or FileLoad actions, choosing between them depending on current screen. Something like

Code: Select all

if title == "Save":
     action [SetVariable("saves_left", saves_left - 1), FileSave(slot)]
else:
    action FileLoad(slot)
At this point I highly recommend to drop file_slots screen and design your own, or eventually it will littered with title == "Save" checks.
Tks I will try this! And yes, I want to design my own screen because it should be accessed inside the game, not in the menu.
Working on many weird narrative games at Curse Box Studios
Image
https://www.curseboxstudios.com/

User avatar
neometalero
Regular
Posts: 198
Joined: Sun Oct 23, 2016 3:51 am
Completed: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Projects: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Deviantart: neometalero
Contact:

Re: Limit the Saves (Resident Evil Style)

#10 Post by neometalero »

When I run that code is not limiting the saves.
Working on many weird narrative games at Curse Box Studios
Image
https://www.curseboxstudios.com/

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2406
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Limit the Saves (Resident Evil Style)

#11 Post by Ocelot »

Works for me: https://i.imgur.com/hLdeQTW.gif

You probably did something wrong.

There are all changes I did to a new project:

Code: Select all

# Button code:
                    button:
                        if title == "Save":
                             action [SetVariable("saves_left", saves_left - 1), FileSave(slot)]
                        else:
                            action FileLoad(slot)

                        if title == "Save": # reuse sacreen argument to avoid a bunch of python code determining current screen
                            sensitive saves_left > 0 # saves_left is your variable where you store amount of saves

                        has vbox

                        add FileScreenshot(slot) xalign 0.5

                        text FileTime(slot, format=_("{#file_time}%A, %B %d %Y, %H:%M"), empty=_("empty slot")):
                            style "slot_time_text"

                        text FileSaveName(slot):
                            style "slot_name_text"

                        key "save_delete" action FileDelete(slot)


# In script file at top level:
default saves_left = 1
< < insert Rick Cook quote here > >

User avatar
neometalero
Regular
Posts: 198
Joined: Sun Oct 23, 2016 3:51 am
Completed: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Projects: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Deviantart: neometalero
Contact:

Re: Limit the Saves (Resident Evil Style)

#12 Post by neometalero »

Ocelot wrote: Wed May 10, 2023 6:37 pm Works for me: https://i.imgur.com/hLdeQTW.gif

You probably did something wrong.

There are all changes I did to a new project:

Code: Select all

# Button code:
                    button:
                        if title == "Save":
                             action [SetVariable("saves_left", saves_left - 1), FileSave(slot)]
                        else:
                            action FileLoad(slot)

                        if title == "Save": # reuse sacreen argument to avoid a bunch of python code determining current screen
                            sensitive saves_left > 0 # saves_left is your variable where you store amount of saves

                        has vbox

                        add FileScreenshot(slot) xalign 0.5

                        text FileTime(slot, format=_("{#file_time}%A, %B %d %Y, %H:%M"), empty=_("empty slot")):
                            style "slot_time_text"

                        text FileSaveName(slot):
                            style "slot_name_text"

                        key "save_delete" action FileDelete(slot)


# In script file at top level:
default saves_left = 1
Now it worked!! Tks a lot! I think I will be able to create a new save screen with that.
Working on many weird narrative games at Curse Box Studios
Image
https://www.curseboxstudios.com/

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]