Page 1 of 1
Array values reset when reloading (Solved)
Posted: Thu Jul 23, 2015 7:04 am
by Steamgirl
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?
Re: Array values reset when reloading
Posted: Thu Jul 23, 2015 7:27 am
by xela
It's neither, you need to define your list (and all variables) either using the define statement or after label start.
Re: Array values reset when reloading
Posted: Thu Jul 23, 2015 7:55 am
by Steamgirl
Hi xela,
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]
Re: Array values reset when reloading
Posted: Thu Jul 23, 2015 8:08 am
by xela
My bad, I always use python after label start.
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]
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.
Re: Array values reset when reloading
Posted: Thu Jul 23, 2015 8:14 am
by trooper6
ETA: Ninja'd
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"]
Or do this:
Code: Select all
label start:
$wedding_choice_text = ["Rings", "Wedding Dress", "Cake", "Flowers", "Venue", "Guest List", "Register Office", "Bridesmaids", "Photographer"]
Re: Array values reset when reloading
Posted: Thu Jul 23, 2015 8:22 am
by Steamgirl
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"]
Re: Array values reset when reloading
Posted: Thu Jul 23, 2015 11:49 am
by trooper6
First off, this should be in the questions thread.
Secondly, could you post your code and error message?
Re: Array values reset when reloading
Posted: Thu Jul 23, 2015 11:51 am
by PyTom
Also, Steamgirl should update to 6.99.5, as the default statement was recently introduced.
Re: Array values reset when reloading
Posted: Thu Jul 23, 2015 2:25 pm
by Steamgirl
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!
