- Site Map >
- Modding and Creation >
- Sims 3 Creation >
- Modding Discussion >
- How to store informations in saved game
- Site Map >
- Modding and Creation >
- Sims 3 Creation >
- Modding Discussion >
- How to store informations in saved game
Replies: 2 (Who?), Viewed: 4344 times.
#1
30th May 2017 at 7:54 PM
Posts: 46
How to store informations in saved game
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 ?
Advertisement
#2
10th Jun 2017 at 8:33 PM
Posts: 299
Thanks: 1054 in 2 Posts
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.
#3
24th Dec 2017 at 10:01 PM
Posts: 46
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 ?
Who Posted
|