Array values reset when reloading (Solved)
- Steamgirl
- Veteran
- Posts: 322
- Joined: Sat Jul 28, 2012 4:39 am
- Completed: My Cup of Coffee, Queen at Arms (co-wrote a battle scene)
- Projects: Stranded Hearts, Emma: A Lady's Maid
- Deviantart: steamgirlgame
- Contact:
Array values reset when reloading (Solved)
So I came across this weird bug this morning that I couldn't for the life of me figure out. I had a menu that showed buttons depending on some values in an array, and everything worked in the game until about halfway through when suddenly all the values reset. I searched my script to see what on Earth could be causing it, but couldn't find anything. I played through the game again (from a fresh start) and it worked this time round. Then later it didn't work again.
I spend a bunch of time tracking it down until I thought... hang on, it happened after I reloaded. Surely it couldn't be resetting the values?! Then I tested it by running the game, going to the custom menu - everything looked correct. I reload and VOILA the bug happened! Reproduceable 5/5 times.
Unlike variables outside of arrays, which don't reset to default upon reload, variables in arrays do! Is this a bug or intentional?
I spend a bunch of time tracking it down until I thought... hang on, it happened after I reloaded. Surely it couldn't be resetting the values?! Then I tested it by running the game, going to the custom menu - everything looked correct. I reload and VOILA the bug happened! Reproduceable 5/5 times.
Unlike variables outside of arrays, which don't reset to default upon reload, variables in arrays do! Is this a bug or intentional?
Last edited by Steamgirl on Thu Jul 23, 2015 2:25 pm, edited 1 time in total.

Hobby Projects: Stranded Hearts | Emma: A Lady's Maid | My Cup of Coffee: The Trouble with Earl Grey
Re: Array values reset when reloading
It's neither, you need to define your list (and all variables) either using the define statement or after label start.
- Steamgirl
- Veteran
- Posts: 322
- Joined: Sat Jul 28, 2012 4:39 am
- Completed: My Cup of Coffee, Queen at Arms (co-wrote a battle scene)
- Projects: Stranded Hearts, Emma: A Lady's Maid
- Deviantart: steamgirlgame
- Contact:
Re: Array values reset when reloading
Hi xela,
Thanks for the suggestion! I tried using define but the issue still happens? Is it because it's in "init"?
Thanks for the suggestion! I tried using define but the issue still happens? Is it because it's in "init"?
Code: Select all
init:
$ wedding_choice = 0
define wedding_choice_text = ["Rings", "Wedding Dress", "Cake", "Flowers", "Venue", "Guest List", "Register Office", "Bridesmaids", "Photographer"]
define wedding_choice_done = [False, False, False, False, False, False, False, False, False]
define wedding_choice_cost = [10, 25, 25, 10, 50, 5, 10, 10, 25]

Hobby Projects: Stranded Hearts | Emma: A Lady's Maid | My Cup of Coffee: The Trouble with Earl Grey
Re: Array values reset when reloading
My bad, I always use python after label start.
Correct way is:
It does not matter if it is in the init or not.
Wedding choice should also be declared in the same way or it will also reset.
Correct way is:
Code: Select all
$ wedding_choice = 0
default wedding_choice_text = ["Rings", "Wedding Dress", "Cake", "Flowers", "Venue", "Guest List", "Register Office", "Bridesmaids", "Photographer"]
default wedding_choice_done = [False, False, False, False, False, False, False, False, False]
default wedding_choice_cost = [10, 25, 25, 10, 50, 5, 10, 10, 25]Wedding choice should also be declared in the same way or it will also reset.
- trooper6
- Lemma-Class Veteran
- Posts: 3712
- Joined: Sat Jul 09, 2011 10:33 pm
- Projects: A Close Shave
- Location: Medford, MA
- Contact:
Re: Array values reset when reloading
ETA: Ninja'd
Xela is correct, but made a typo with the keyword.
Either do this (which is the brand new way):
Or do this:
Xela is correct, but made a typo with the keyword.
Either do this (which is the brand new way):
Code: Select all
default wedding_choice_text = ["Rings", "Wedding Dress", "Cake", "Flowers", "Venue", "Guest List", "Register Office", "Bridesmaids", "Photographer"]Code: Select all
label start:
$wedding_choice_text = ["Rings", "Wedding Dress", "Cake", "Flowers", "Venue", "Guest List", "Register Office", "Bridesmaids", "Photographer"]A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?) Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?) Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978
- Steamgirl
- Veteran
- Posts: 322
- Joined: Sat Jul 28, 2012 4:39 am
- Completed: My Cup of Coffee, Queen at Arms (co-wrote a battle scene)
- Projects: Stranded Hearts, Emma: A Lady's Maid
- Deviantart: steamgirlgame
- Contact:
Re: Array values reset when reloading
Well that's just the thing, variables outside of arrays don't reset upon reloading so it doesn't matter for wedding_choice. It's never mattered for any variables before which is why I didn't think it would matter for arrays.
When I use default it gives me an "expected statement" error?
default wedding_choice_text (pointy red arrow)= ["Rings", "Wedding Dress", "Cake", "Flowers", "Venue", "Guest List", "Register Office", "Bridesmaids", "Photographer"]
When I use default it gives me an "expected statement" error?
default wedding_choice_text (pointy red arrow)= ["Rings", "Wedding Dress", "Cake", "Flowers", "Venue", "Guest List", "Register Office", "Bridesmaids", "Photographer"]

Hobby Projects: Stranded Hearts | Emma: A Lady's Maid | My Cup of Coffee: The Trouble with Earl Grey
- trooper6
- Lemma-Class Veteran
- Posts: 3712
- Joined: Sat Jul 09, 2011 10:33 pm
- Projects: A Close Shave
- Location: Medford, MA
- Contact:
Re: Array values reset when reloading
First off, this should be in the questions thread.
Secondly, could you post your code and error message?
Secondly, could you post your code and error message?
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?) Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?) Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978
- PyTom
- Ren'Py Creator
- Posts: 15893
- Joined: Mon Feb 02, 2004 10:58 am
- Completed: Moonlight Walks
- Projects: Ren'Py
- IRC Nick: renpytom
- Github: renpytom
- itch: renpytom
- Location: Kings Park, NY
- Contact:
Re: Array values reset when reloading
Also, Steamgirl should update to 6.99.5, as the default statement was recently introduced.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom(When was the last time you backed up your game?)
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom
- Steamgirl
- Veteran
- Posts: 322
- Joined: Sat Jul 28, 2012 4:39 am
- Completed: My Cup of Coffee, Queen at Arms (co-wrote a battle scene)
- Projects: Stranded Hearts, Emma: A Lady's Maid
- Deviantart: steamgirlgame
- Contact:
Re: Array values reset when reloading
Thanks for all the help everyone! I just saw another similar thread so I feel like a right derp for duplication!
Also, I'm an idiot for not trying to update my version of renpy before posting here, hehe.
Default works! Hurrah!
Also, I'm an idiot for not trying to update my version of renpy before posting here, hehe.
Default works! Hurrah!

Hobby Projects: Stranded Hearts | Emma: A Lady's Maid | My Cup of Coffee: The Trouble with Earl Grey
Who is online
Users browsing this forum: No registered users
