Welcome to
Mod The Sims
Online: 1517
News:
Have an account? Sign in:
pass:
If you don't have an account, why not sign up now? It's free!
Other sites: SimsWiki
Reply  Replies: 2 (Who?), Viewed: 3608 times.
Search this Thread
Old 30th May 2017, 7:54 PM DefaultHow to store informations in saved game #1
Armise
Original Poster

Test Subject

Join Date: Aug 2014
Posts: 42


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 ?
Old 10th Jun 2017, 8:33 PM #2
pjsutton
Field Researcher

Join Date: Feb 2015
Posts: 269
Thanks: 567 in 6 Posts
5 Achievements


Quote:
Originally Posted by Armise
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 ?


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:

Code:

[PersistableStatic]
public static bool BoardingActivated;
[PersistableStatic]
public static List<ulong> BoardingStatus;

[PersistableStatic]
public static Dictionary<ulong, float> BoardingCost;

[PersistableStatic]
public static Dictionary<SimDescription, ulong> BoardedHorses;

[PersistableStatic]
public static float BoardMultipler;



You'd probably want to have a dictionary like

Code:
[PersistableStatic]
public static Dictionary<SimDescription, int> FaithValue;


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.
Old 24th Dec 2017, 10:01 PM #3
Armise
Original Poster

Test Subject

Join Date: Aug 2014
Posts: 42


Quote:
Originally Posted by pjsutton
You'd probably want to have a dictionary like

Code:
[PersistableStatic]
public static Dictionary<SimDescription, int> FaithValue;


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.


Thank you !
I guess to add a sim in the dict with 0 as a level of faith, i would do :
Code:
foreach (Sim sim in Sims3.Gameplay.Queries.GetObjects<Sim>())
{
if (sim != null)
{
FaithValue.Add(sim.SimDescription, 0)
}
}

And the faith value of a sim is :
Code:
FaithValue[sim.SimDescription]


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 ?
Reply


Section jump:


Powered by MariaDB Some icons by http://dryicons.com.