create new game in main menu that delete all save game and persistent data

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
Mjhay
Regular
Posts: 61
Joined: Sat Jan 16, 2021 2:29 pm
Location: Philippines
Contact:

create new game in main menu that delete all save game and persistent data

#1 Post by Mjhay » Mon Feb 22, 2021 5:02 am

how can i create new game textbutton in main menu and delete all saves game and all the persistent data in the game ? and create new game
dont know what to do.

User avatar
hell_oh_world
Miko-Class Veteran
Posts: 777
Joined: Fri Jul 12, 2019 5:21 am
Projects: The Button Man
Organization: NILA
Github: hell-oh-world
Location: Philippines
Contact:

Re: create new game in main menu that delete all save game and persistent data

#2 Post by hell_oh_world » Mon Feb 22, 2021 5:51 am

how can i create new game textbutton in main menu and delete all saves game

Code: Select all

init python:
  def fileDeleteAll():
    for s in renpy.list_saved_games():
      renpy.unlink_save(s[0])
  
  def FileDeleteAll(confirm=True, message=_("Do you really wish to delete all your saved games?")):
    action = Function(fileDeleteAll)
    
    if confirm:
      action = Confirm(message, action)
      
    return action
    
screen your_screen():
  textbutton "Delete All Saved Games":
    action FileDeleteAll()
all the persistent data in the game ?

Code: Select all

screen your_screen():
  textbutton "Clear Persistent":
    action Function(persistent._clear, True)
create new game in main menu that delete all save game and persistent data
combining the two, you could come up with this.

Code: Select all

init python:
  def fileDeleteAll():
    for s in renpy.list_saved_games():
      renpy.unlink_save(s[0])

  def newGame(*args, **kwargs):
    persistent._clear(True)
    fileDeleteAll()
    renpy.run(Start(*args, **kwargs))

  def NewGame(*args, **kwargs): return Function(newGame, *args, **kwargs)

screen your_screen():
  textbutton "New Game":
    action NewGame() # once clicked it should go to the label `start`, of your script

cheonbyeol
Regular
Posts: 37
Joined: Thu Feb 04, 2021 9:04 am
Contact:

Re: create new game in main menu that delete all save game and persistent data

#3 Post by cheonbyeol » Mon Feb 22, 2021 9:15 am

Are you trying to do something like the otome game Nameless? There, when playing the second hidden route, the game "deletes" all your data, but gives it back once you clear that route. In case you want to do something like that, I'd be much more careful with actually deleting stuff, rather just hide it.

User avatar
Mjhay
Regular
Posts: 61
Joined: Sat Jan 16, 2021 2:29 pm
Location: Philippines
Contact:

Re: create new game in main menu that delete all save game and persistent data

#4 Post by Mjhay » Tue Feb 23, 2021 8:53 am

hell_oh_world wrote:
Mon Feb 22, 2021 5:51 am
how can i create new game textbutton in main menu and delete all saves game

Code: Select all

init python:
  def fileDeleteAll():
    for s in renpy.list_saved_games():
      renpy.unlink_save(s[0])
  
  def FileDeleteAll(confirm=True, message=_("Do you really wish to delete all your saved games?")):
    action = Function(fileDeleteAll)
    
    if confirm:
      action = Confirm(message, action)
      
    return action
    
screen your_screen():
  textbutton "Delete All Saved Games":
    action FileDeleteAll()
all the persistent data in the game ?

Code: Select all

screen your_screen():
  textbutton "Clear Persistent":
    action Function(persistent._clear, True)
create new game in main menu that delete all save game and persistent data
combining the two, you could come up with this.

Code: Select all

init python:
  def fileDeleteAll():
    for s in renpy.list_saved_games():
      renpy.unlink_save(s[0])

  def newGame(*args, **kwargs):
    persistent._clear(True)
    fileDeleteAll()
    renpy.run(Start(*args, **kwargs))

  def NewGame(*args, **kwargs): return Function(newGame, *args, **kwargs)

screen your_screen():
  textbutton "New Game":
    action NewGame() # once clicked it should go to the label `start`, of your script
oh it works ! salamat po :D para sa thesis

on load game, the quick save up to the other page together with the persistent data are all deleted, it all works thanks to that. :)

but except in the automatic save's part is not deleted, do you know about that?

User avatar
Mjhay
Regular
Posts: 61
Joined: Sat Jan 16, 2021 2:29 pm
Location: Philippines
Contact:

Re: create new game in main menu that delete all save game and persistent data

#5 Post by Mjhay » Tue Feb 23, 2021 8:58 am

cheonbyeol wrote:
Mon Feb 22, 2021 9:15 am
Are you trying to do something like the otome game Nameless? There, when playing the second hidden route, the game "deletes" all your data, but gives it back once you clear that route. In case you want to do something like that, I'd be much more careful with actually deleting stuff, rather just hide it.
um its not like that, :) all i want is when the user create new game its like the game will restart from the beginning and all the save game and persistent data will lost or deleted. even the automatic saves :)

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3636
Joined: Mon Dec 14, 2015 5:05 am
Location: Your monitor
Contact:

Re: create new game in main menu that delete all save game and persistent data

#6 Post by Imperf3kt » Tue Feb 23, 2021 4:29 pm

I assume you will inform the player before they do so, otherwise I can sense a lot of hatred and harassment may be directed at you from your players. People don't take well to save file deletions, especially unexpected ones.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor
Free Android GUI - Updated occasionally
Twitter
Imperf3kt Blackjack - a WIP blackjack game for Android made using Ren'Py

cheonbyeol
Regular
Posts: 37
Joined: Thu Feb 04, 2021 9:04 am
Contact:

Re: create new game in main menu that delete all save game and persistent data

#7 Post by cheonbyeol » Tue Feb 23, 2021 4:35 pm

I second what Imperf3kt says.
I suggest you warn them when they start the first game already, so they know when to make the saves so they can explore branches without restarting.
When you delete persistent data, also the data of which lines have been seen is lost, so they can't even "skip read text".
Plus, if they unlocked CGs and stuff...
Well, that's all unless the point is exactly to mess with the player...? But the game should probably disclaim that.

User avatar
Mjhay
Regular
Posts: 61
Joined: Sat Jan 16, 2021 2:29 pm
Location: Philippines
Contact:

Re: create new game in main menu that delete all save game and persistent data

#8 Post by Mjhay » Tue Feb 23, 2021 8:00 pm

Imperf3kt wrote:
Tue Feb 23, 2021 4:29 pm
I assume you will inform the player before they do so, otherwise I can sense a lot of hatred and harassment may be directed at you from your players. People don't take well to save file deletions, especially unexpected ones.
Your right . Im will put confirmation . 😊 thanks for the advice

User avatar
hell_oh_world
Miko-Class Veteran
Posts: 777
Joined: Fri Jul 12, 2019 5:21 am
Projects: The Button Man
Organization: NILA
Github: hell-oh-world
Location: Philippines
Contact:

Re: create new game in main menu that delete all save game and persistent data

#9 Post by hell_oh_world » Wed Feb 24, 2021 12:37 am

Mjhay wrote:
Tue Feb 23, 2021 8:53 am
oh it works ! salamat po :D para sa thesis

on load game, the quick save up to the other page together with the persistent data are all deleted, it all works thanks to that. :)

but except in the automatic save's part is not deleted, do you know about that?
I tried the code seems to work for all saved games. The thing is renpy automatically creates the autosave slots once you try to exit the game. You can confirm that by checking the saves folder after trying to press the x button on the window, also autosave occurs at a certain point in time, maybe every 10 mins, I forgot the exact time, but I know its documented somewhere (try searching for renpy config variables). So maybe that's why you thought that it does not do its job after you closed the game.
If you want to disable autosave you can try putting in your code `define config.has_autosave = False`.

Good luck as thesis nyo ^^. Nasa plano ko rin na gamitin Ren'Py samin e haha.

User avatar
Mjhay
Regular
Posts: 61
Joined: Sat Jan 16, 2021 2:29 pm
Location: Philippines
Contact:

Re: create new game in main menu that delete all save game and persistent data

#10 Post by Mjhay » Wed Feb 24, 2021 1:18 am

hell_oh_world wrote:
Wed Feb 24, 2021 12:37 am
Mjhay wrote:
Tue Feb 23, 2021 8:53 am
oh it works ! salamat po :D para sa thesis

on load game, the quick save up to the other page together with the persistent data are all deleted, it all works thanks to that. :)

but except in the automatic save's part is not deleted, do you know about that?
I tried the code seems to work for all saved games. The thing is renpy automatically creates the autosave slots once you try to exit the game. You can confirm that by checking the saves folder after trying to press the x button on the window, also autosave occurs at a certain point in time, maybe every 10 mins, I forgot the exact time, but I know its documented somewhere (try searching for renpy config variables). So maybe that's why you thought that it does not do its job after you closed the game.
If you want to disable autosave you can try putting in your code `define config.has_autosave = False`.

Good luck as thesis nyo ^^. Nasa plano ko rin na gamitin Ren'Py samin e haha.
i try to add confirmation message in fileDeleteAll(): but its not working. theres no Confirmation message .
but when i create new game all the data is deleted but still theres no confirmation message. sorry

im not trying to disable the autosave cuz in this feature its a big help for the user, haha
and im making an educational android game in computer system servicing. :)
student karin pala, galing mo ha my CLASS ka . lodi :D
im not good in programming search search lang ako. hahaha but thanks for your help

User avatar
Mjhay
Regular
Posts: 61
Joined: Sat Jan 16, 2021 2:29 pm
Location: Philippines
Contact:

Re: create new game in main menu that delete all save game and persistent data

#11 Post by Mjhay » Wed Feb 24, 2021 2:53 am

oh i get it now.. hehe it all works an have a confirmation message . :)
thanks to all of you.

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot]