Limit the Saves (Resident Evil Style)
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.
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.
- 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)
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?
- Ocelot
- Lemma-Class Veteran
- Posts: 2407
- Joined: Tue Aug 23, 2016 10:35 am
- Github: MiiNiPaa
- Discord: MiiNiPaa#4384
- Contact:
Re: Limit the Saves (Resident Evil Style)
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 > >
- 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)
How can I disable/enable those screen? Im not finding any usefull post about that.
- Ocelot
- Lemma-Class Veteran
- Posts: 2407
- Joined: Tue Aug 23, 2016 10:35 am
- Github: MiiNiPaa
- Discord: MiiNiPaa#4384
- Contact:
Re: Limit the Saves (Resident Evil Style)
If you are using default GUI, you need to modify file_slots screen and change the save buttons to be something like that:
Ideally, you would replace default save/load screen with separate custom screens, so you can drop current screen check and simplify code.
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
< < insert Rick Cook quote here > >
- 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)
So I would need to modify the section screen file_slots(title): inside the Screens file right?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:Ideally, you would replace default save/load screen with separate custom screens, so you can drop current screen check and simplify code.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
- Ocelot
- Lemma-Class Veteran
- Posts: 2407
- Joined: Tue Aug 23, 2016 10:35 am
- Github: MiiNiPaa
- Discord: MiiNiPaa#4384
- Contact:
Re: Limit the Saves (Resident Evil Style)
Yes, in particular the save button itself (it is the one within grid in that screen).
< < insert Rick Cook quote here > >
- 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)
I tried this
But the part that substract 1 from the remaining saves is not working. Any idea whats wrong?
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
- Ocelot
- Lemma-Class Veteran
- Posts: 2407
- Joined: Tue Aug 23, 2016 10:35 am
- Github: MiiNiPaa
- Discord: MiiNiPaa#4384
- Contact:
Re: Limit the Saves (Resident Evil Style)
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
At this point I highly recommend to drop file_slots screen and design your own, or eventually it will littered with title == "Save" checks.
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)
< < insert Rick Cook quote here > >
- 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)
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.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 likeAt this point I highly recommend to drop file_slots screen and design your own, or eventually it will littered with title == "Save" checks.Code: Select all
if title == "Save": action [SetVariable("saves_left", saves_left - 1), FileSave(slot)] else: action FileLoad(slot)
- 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)
When I run that code is not limiting the saves.
- Ocelot
- Lemma-Class Veteran
- Posts: 2407
- Joined: Tue Aug 23, 2016 10:35 am
- Github: MiiNiPaa
- Discord: MiiNiPaa#4384
- Contact:
Re: Limit the Saves (Resident Evil Style)
Works for me: https://i.imgur.com/hLdeQTW.gif
You probably did something wrong.
There are all changes I did to a new project:
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 > >
- 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)
Now it worked!! Tks a lot! I think I will be able to create a new save screen with that.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
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot]