Saving & And Loading Custom Defined classes

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
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.
Post Reply
Message
Author
TearStar
Newbie
Posts: 1
Joined: Sat Aug 11, 2018 5:07 pm
Contact:

Saving & And Loading Custom Defined classes

#1 Post 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...

Post Reply

Who is online

Users browsing this forum: RandomHuman64