I was under the impression that variables would reset at the end of a call but I think I misunderstood. Here's my situation.
I the player will call a minigame and I finally got it working properly. During the minigame wins/losses will effect the players stats: more money, skills etc.
But DURING the game I have a series of local variables that need to reset at the end of the game. I thought it was going to reset but when I call the minigame again the next day (I have a setting that it can only be plated once a day) it retains the image settings from the last day. My sloppy solution was to just set the variables back to zero (or 1 respectively) when the NewDay function was called. The day resets, the ability to play the game resets, but the variables dont...
I'm trying to figure out what I can do to tell the game to reset the minigame variables at the end of the minigame.
How to reset a variable to default
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.
- namastaii
- Eileen-Class Veteran
- Posts: 1350
- Joined: Mon Feb 02, 2015 8:35 pm
- Projects: Template Maker for Ren'Py, What Life
- Github: lunalucid
- Skype: Discord: lunalucid#1991
- Soundcloud: LunaLucidMusic
- itch: lunalucid
- Location: USA
- Contact:
Re: How to reset a variable to default
I'm not sure if there is a code specifically but you could make your own? create a function and list all the variables within the function to get set to 0 or whatever it need be and you can call that function when needed? or include it more specifically in your newday function. I haven't messed with persistent stuff but you could try persistent._clear()?
- Kia
- Eileen-Class Veteran
- Posts: 1040
- Joined: Fri Aug 01, 2014 7:49 am
- Deviantart: KiaAzad
- Discord: Kia#6810
- Contact:
Re: How to reset a variable to default
the solution is defining your variables inside the minigame screen, if your minigame is a screen of course.
this way every time you open your minigame, the variables are re-assigned.
if your minigame does not have a screen, it should be contained inside a label and the variables defined at the top of the label
this way every time you open your minigame, the variables are re-assigned.
if your minigame does not have a screen, it should be contained inside a label and the variables defined at the top of the label
Who is online
Users browsing this forum: Google [Bot]