How to save a data of a class?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Xian

Hello, I stored my entire game in an inner class of my autoload script. My problem is when I save the class, what is being saved is the reference to the class and not the data of the class. What should I do?

:bust_in_silhouette: Reply From: Kyle Szklenski

Probably the easiest way to handle that is to make a method on your inner class that returns a dictionary containing the data you want to save. Then, when you save that class, save instead a call to that method. Similarly, when reloading, have a method which goes and looks at the specific keys you want to set on your inner class and set them appropriately. Does that make sense?