|Search this Thread|
|30th May 2017, 8:54 PM||How to store informations in saved game #1|
I'm trying to make my mod store an int variable, one per sim in the game, to know if they are on the good or evil side of their faith. It's a bit like the sexual orientation variable that exists in the original game, except the gender preference is a private int variable inside the "Sim" class. Anyway.
I know variable storing is possible, cause mods like twallan's use it to store mod options parameters.
Now, my idea is to store just one big dictionnary-type variable, which would relate the said faith variable to, say, each Sim name (or any unique property of the Sim).
I just can't figure out how to make the game (or the mod) store the variable. Any ideas ?
|10th Jun 2017, 9:33 PM||#2|
Join Date: Feb 2015
It needs to be persistable.
You need to add [assembly: PersistableStatic] into you AssemblyInfo.cs file. I also throw [Assembly: Tunable] in there at the same time.
Then, when you declare your Dictionary, put [Persistable] above it. Here's a bunch of examples from my Horse Boarding mod:
You'd probably want to have a dictionary like
Then store the int with that Sim's SimDescription. IDK what else you are doing but you could have it check the Dictionary when you load up a game / household and change that value if necessary.
|24th Dec 2017, 11:01 PM||#3|
Thank you !
I guess to add a sim in the dict with 0 as a level of faith, i would do :
And the faith value of a sim is :
But how do I check wether or not there already is an instance of this dictionnary already existing in the game ?
My namespace is (currently) Armise and my class is AngelsAndDemons (name of my mod), do I call the dictionary Armise.AngelsAndDemons.FaithValue ? this.FaithValue ?