Save some things by ref and others by val

Discussion and help for Easy Save 3
Post Reply
gooby
Posts: 3
Joined: Wed Dec 30, 2020 1:35 am

Save some things by ref and others by val

Post by gooby »

Hello, I bought easy save today and have been learning to use it.

Unfortunately the way i made the random weapon system in my game makes saving difficult even with this plugin.

ANyway, my question is how can i save some objects by reference (such as scriptable objects that represent the base weapons) and other objects by their value (the generated scriptable objects that i deconstruct on saving and reconstruct on loading)?

I want to specifically save the random values like damage) by value in that generated SO, but i want to save the unchanging SOs that represent it, such as the base stat types and base weapon.
User avatar
Joel
Moodkie Staff
Posts: 4859
Joined: Wed Nov 07, 2012 10:32 pm

Re: Save some things by ref and others by val

Post by Joel »

Hi there,

You can do this by creating an ES3Type file and modify it as described here:
https://docs.moodkie.com/easy-save-3/es ... g-es3types

And then you can use the third parameter of the writer.WriteProperty method to choose how it is written:

Code: Select all

// By value
writer.WriteProperty("myProperty", instance.myProperty, ES3.ReferenceMode.ByValue);
// By reference
writer.WriteProperty("myProperty", instance.myProperty, ES3.ReferenceMode.ByRef);
// By reference and value
// I.e. if a reference already exists with that ID, it'll load the data into that reference.
// Otherwise, it will create a new instance and load the data into that.
writer.WriteProperty("myProperty", instance.myProperty, ES3.ReferenceMode.ByRefAndValue);[/code]

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
gooby
Posts: 3
Joined: Wed Dec 30, 2020 1:35 am

Re: Save some things by ref and others by val

Post by gooby »

Joel wrote: Wed Dec 30, 2020 8:46 am Hi there,

You can do this by creating an ES3Type file and modify it as described here:
https://docs.moodkie.com/easy-save-3/es ... g-es3types

And then you can use the third parameter of the writer.WriteProperty method to choose how it is written:

Code: Select all

// By value
writer.WriteProperty("myProperty", instance.myProperty, ES3.ReferenceMode.ByValue);
// By reference
writer.WriteProperty("myProperty", instance.myProperty, ES3.ReferenceMode.ByRef);
// By reference and value
// I.e. if a reference already exists with that ID, it'll load the data into that reference.
// Otherwise, it will create a new instance and load the data into that.
writer.WriteProperty("myProperty", instance.myProperty, ES3.ReferenceMode.ByRefAndValue);[/code]

All the best,
Joel
still doesn't seem to be working for me, it's still saying that its trying to get a reference thats not in the manager. will have to take another look at my system, thanks for the help tho! :D
Post Reply