Ren'Py Class stats keep being reset

aPieceOfTissue

Newbie
Game Developer
Jan 22, 2019
40
86
I am new coding and I'm still learning about it. There is a problem with saving the stats data in my game. My game is running without a problem but every time I turn off the game and load the saved file, my character stats data is set back to 0. Here is the code:

Python:
init python:
    class Chara(object):
        def __init__(self, name, love):
            self.name = name
            self.love = love

    STATS = [],
    t = 0

    while t < 50:
        STATS.append(Chara("none", 0))
        t += 1
       
label variables:

    $ STATS[0] = Chara("Laura", 1)
I have search about it online and I think it may have something to do with the "default" and "$" thing, but I can't figure out how to make it right. Please give me some advice. Thanks.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,969
16,222
There is a problem with saving the stats data in my game.
Strictly speaking, there's no problem. The data aren't presented as savable, and therefore aren't saved. But obviously, practically speaking there's a big problem, since you want them to be saved.

For this you need to declare the list correctly, through default STATS = []. What imply that you can not anymore populate it in an init block.


Please give me some advice.
You should take a look at the .