Author Topic: Saving objects as *.cs or a third saving system  (Read 653 times)

Hello,

If I were to save some object information, would it be better to script a third saving system — or can I just be lazy and use obj.save()?

What would be the benefits of each solution?

There's nothing wrong with export and .save...as long as they work. The problem is there's some cases where they don't work.

Some characters will break arrays when you try to reload it (see: this thread)
For .save, if a field of the object you're saving is an object, it won't save that object, it will just save the numeric ID of that object, which is meaningless when the game is restarted

If you can get away with using export or save, do so. The overhead for a custom reader/writer is rarely worth the small amount of storage space you'll save. However, if you are writing thousands of lines, and you are concerned about read or write times, then it is best to write a slow reader/writer, so that it doesn't read/write the entire file at once, but rather schedules it out so that it only does a few hundred lines at a time.

Writing a saving/loading system can be quite fun though, and its a good learning experience.

keep in mind that if a field on an object can only store 1024 characters. if you exceed that limit, trying .save() on it will crash the game

Thanks everyone, I will take this into consideration.
I think I'll use the methods to do the job, since I need ALL of the information in the object groups.
« Last Edit: October 12, 2015, 03:50:22 PM by Quartz »

keep in mind that if a field on an object can only store 1024 characters. if you exceed that limit, trying .save() on it will crash the game
If you try to save more than 1024 characters to a field you need to rethink life.

What you can do is set the objects as a class name and then save them. This is what I do for my job system, each job has an object, and it saves as a class name of "Job", that way, I use Job::onAdd(%this) to do the rest when I exec them.

What you can do is set the objects as a class name and then save them. This is what I do for my job system, each job has an object, and it saves as a class name of "Job", that way, I use Job::onAdd(%this) to do the rest when I exec them.
Yeah, this makes the whole process more smooth and less prone to errors.