Page 1 of 1

Saving & And Loading Custom Defined classes

Posted: Sat Aug 11, 2018 5:09 pm
by TearStar

Code: Select all

class Quest(object):
        char = ""
        log = ""
        i = 0
        leng = 1
        state = ["", "", "", "" ,""]
        var1 = 0
        var2 = 0
        var3 = 0
        var1_name = ""
        var2_name = ""
        var3_name = ""
        lab_name = ""
        loc = ""
        day_time = ""
        completed = False
        def __init__(self, vname1, vname2,vname3, vval1,vval2,vval3,lname,char,log, loc, dait):
            self.var1_name = vname1
            self.var2_name = vname2
            self.var3_name = vname3
            self.var1 = vval1
            self.var2 = vval2
            self.var3 = vval3
            self.char = char
            self.log = log
            self.state = lname
            self.loc = loc
            self.day_time = dait
            object.__init__(self)
I try to store this classes with associated values to it.

I found some tips along the internet that told me but none of them explained to me clearly and I just ran a circle with problem two minutes ago. (inheriting object class was one of the tips)

Basically I have 8 variables that are used associated with a Quest (all quest are predefined instances, only assinged to one variable e.g. mainQuestOpen = quest_01 where quest_01 is predefined, mainQuestOpen is the one I use).

What did I try:
  • PicklingError: I set up
    define config.use_cpickle = False
    define config.save_dump = True
    These two.. That solved the problem for a while
  • Assingned values in start label
    Got me AttributeError: RevertableObject has no attribute 'char'
  • Inherited the object class
No, I don't want to use variables since you see quest class has serious ammount of variables, times the quest I have I would have 7 million variables...

Any other suggestions I'm open.

I also did something but resuted in:
PicklingError: Can't pickel <class 'store.Quest'>: it's not the same object as store.Quest

I'm stuck here...