I've implemented a "reset all game progress" button which seems to be working just fine. However, when I call the main menu afterwards, the game crashes. I believe this is because my menu has a persistent variable in it and, since I've just deleted them all, it comes up with an error.
If there is a way to restart the game, instead of calling the main menu, I believe this should sort the problem. Is this possible?
Here's my full code. The reset button is in preferences:
Code: Select all
button:
action Show("reset_popup")
style "mainmenu_choice_button"
text "Reset Game" style "mainmenu_choice"
Code: Select all
screen reset_popup:
window:
add "mainmenubg"
hbox:
add "images/popup.png" xanchor 0.0 yanchor 0 xpos 410 ypos 200
vbox:
yanchor 0
xanchor 0.5
ypos 350
xalign 0.5
xmaximum 1000
ymaximum 350
label ("This will reset the game and delete all your progress.\nDo you want to continue?"):
text_style "yesno_label_text"
xalign 0.5
yalign 0.5
hbox:
style "menu"
ypos 300
spacing 70
button:
action Jump("resetprogress")
style "menu_choice_button"
text "Yes" style "menu_choice"
button:
action Return()
style "menu_choice_button"
text "No" style "menu_choice"
key "game_menu" action Jump("resetprogress")
Code: Select all
label resetprogress:
$ persistent._clear(progress=True)
call screen main_menu
Code: Select all
if len(persistent.endings) == 1:
add "whiteout"
hbox:
add "images/popup.png" xanchor 0 yanchor 0 xpos 410 ypos 200
vbox:
yanchor 0
xanchor 0.5
ypos 245
xalign 0.5
xmaximum 1000
ymaximum 350
label _("You have finished your first play-through of... etc etc"):
text_style "yesno_label_text"
xalign 0.5
yalign 0.5
hbox:
style "menu"
xalign 0.5
ypos 100
spacing 70
button:
action [Return(), AddToSet(persistent.endings, 1)]
style "menu_choice_button"
text "Okay" style "menu_choice"
Code: Select all
init -2 python:
if persistent.endings == None:
persistent.endings = []