- Site Map >
- Modding and Creation >
- Sims 3 Creation >
- Modding Discussion >
- Persistable tuples not persisting
- Site Map >
- Modding and Creation >
- Sims 3 Creation >
- Modding Discussion >
- Persistable tuples not persisting
Replies: 11 (Who?), Viewed: 437 times.
#1
29th Nov 2020 at 3:36 PM
Persistable tuples not persisting
I think the issue here must be with my use of tuples in particular, because all the persistable static variables I create in this class except for the dictionaries of tuples (sFosterHomes and FosterHomes) are fine.I'm defining them like this:
Code:
And setting them like this:[PersistableStatic] public static Dictionary<ulong, Tuple> sFosterHomes; public static Dictionary<ulong, Tuple> FosterHomes { get { if (sFosterHomes == null) { sFosterHomes = new Dictionary<ulong, Tuple>(); } return sFosterHomes; } set => sFosterHomes = value; }
Code:
With FosterParents being a persistable static dictionary of ulong keys and int values. They seem to work fine during a save (I'm able to get the parameters of the tuple for a specific household without any apparent problem), and only have problems when reloading.
sFosterHomes.Add(simHouseholdId, new Tuple(FosterParents[simDescriptionId] as object, 0 as object))
Advertisement
Space Pony
#2
29th Nov 2020 at 3:53 PM
Last edited by Battery : 29th Nov 2020 at 4:05 PM.
Posts: 433
Thanks: 782 in 6 Posts
Hmm this might be a silly uestion but did you add the Persistable static to your assembly ?
and are you sure you have to cast these types to object ?
also whats FosterParents ?
and are you sure you have to cast these types to object ?
also whats FosterParents ?
#3
29th Nov 2020 at 4:09 PM
Posts: 437
Thanks: 5285 in 22 Posts
I'm assuming you're talking about Sims3.UI.Tuple? And FosterParents is persisting as expected, right? Those tuple objects are not themselves persistable, even if you put persistable objects in them, so you might need to create your own persistable tuple, as I did here in Job Overhaul:
Note the empty constructor; persistable objects must have a constructor with no arguments in order for the game to capture them.
Code:
namespace Gamefreak130.JobOverhaulSpace.Helpers { [Persistable] public class OccupationEntryTuple { public Occupation OccupationEntry { get; set; } public CareerLocation CareerLocation { get; set; } public OccupationEntryTuple() { } public OccupationEntryTuple(Occupation entry, CareerLocation careerLocation) { OccupationEntry = entry; CareerLocation = careerLocation; } }
Note the empty constructor; persistable objects must have a constructor with no arguments in order for the game to capture them.
"The Internet is the first thing that humanity has built that humanity doesn't understand, the largest experiment in anarchy that we have ever had." - Eric Schmidt
If you enjoy the mods I put out, consider supporting me on patreon: www.patreon.com/Gamefreak130
If you enjoy the mods I put out, consider supporting me on patreon: www.patreon.com/Gamefreak130
#4
29th Nov 2020 at 4:09 PM
I have! I learned my lesson after the last time I spent like a day trying to understand why nothing was persisting
Hm, I think casting to object is necessary? That was my interpretation of the Tuple constructor in Sims3.UI:
EDIT: Oh hey simultaneous post! FosterParents is persisting, yeah - I'll give creating my own peristable tuple a try!
Hm, I think casting to object is necessary? That was my interpretation of the Tuple constructor in Sims3.UI:
Code:
But I could be misunderstanding how the object type is supposed to be used. I also haven't been able to find many examples of Tuples being used like this, so I'm thinking about just going back to my array-using roots and storing the two ints I need in an array instead of a special structure like this.public Tuple(object param1, object param2) { mParam1 = param1; mParam2 = param2; }
EDIT: Oh hey simultaneous post! FosterParents is persisting, yeah - I'll give creating my own peristable tuple a try!
Space Pony
#5
29th Nov 2020 at 4:12 PM
Posts: 433
Thanks: 782 in 6 Posts
Hmm, you might need to make your own tuple class and make it persistable aswell
E: ok a bit to late can you post what the type of FosterParents[simDescriptionId] is ?
E: ok a bit to late can you post what the type of FosterParents[simDescriptionId] is ?
#6
29th Nov 2020 at 4:19 PM
Posts: 437
Thanks: 5285 in 22 Posts
As an aside, I think Battery's right in that casting to object there wasn't explicitly necessary (and VS would have told you about it ). All objects in C# are inherently...well...objects, and the language allows derived types to be passed as their base type without any explicit casting.
"The Internet is the first thing that humanity has built that humanity doesn't understand, the largest experiment in anarchy that we have ever had." - Eric Schmidt
If you enjoy the mods I put out, consider supporting me on patreon: www.patreon.com/Gamefreak130
If you enjoy the mods I put out, consider supporting me on patreon: www.patreon.com/Gamefreak130
#7
29th Nov 2020 at 4:38 PM
@Battery FosterParents[simDescriptionId] is an int. Hey, is the reason the Tuple class in Sims3.UI isn't persistable that it doesn't have an empty constructor?
I've created my own persistable tuple and am testing it now - thanks, I'll update on how it works!
Edit: It worked! Thanks a lot, both of you! :D
I've created my own persistable tuple and am testing it now - thanks, I'll update on how it works!
Edit: It worked! Thanks a lot, both of you! :D
#8
29th Nov 2020 at 6:24 PM
Posts: 973
Thanks: 1897 in 12 Posts
Ah! So you're the one working on the better foster system, lizcandor!
I'm trying to figure out how persistable data works for my custom skill, and I'm reading all over the forums on it. It's confusing :-/.
Echo Weaver's Simblr: http://echoweaver.tumblr.com/
A portrait in stubbornness - Playing the same legacy since 2009
Sample a Brave Legacy: http://sims3sample.illation.net
I'm trying to figure out how persistable data works for my custom skill, and I'm reading all over the forums on it. It's confusing :-/.
Echo Weaver's Simblr: http://echoweaver.tumblr.com/
A portrait in stubbornness - Playing the same legacy since 2009
Sample a Brave Legacy: http://sims3sample.illation.net
#9
29th Nov 2020 at 8:52 PM
I keep thinking I understand persistable data now and then realizing that I actually do not An especially sad example of a persistable data failure from earlier in this project: the class I was using to move groups of sims through the child protective services system wasn't persisting (which I now realize was because it hadn't had an empty constructor!) so if I quit and reloaded anytime between moving sims out of their original household for neglect and trying to return them, their case would get destroyed and they'd just be stranded wherever they were put.
#10
30th Nov 2020 at 5:14 AM
Posts: 973
Thanks: 1897 in 12 Posts
Argh. I've been trying to read through the forum to get a picture of how Persistable data works, but I still don't think I get it. I'm just doing custom skills, and I'm hoping that if I copy from the sewing table by rote, I'll get away with it....
Echo Weaver's Simblr: http://echoweaver.tumblr.com/
A portrait in stubbornness - Playing the same legacy since 2009
Sample a Brave Legacy: http://sims3sample.illation.net
Echo Weaver's Simblr: http://echoweaver.tumblr.com/
A portrait in stubbornness - Playing the same legacy since 2009
Sample a Brave Legacy: http://sims3sample.illation.net
#11
30th Nov 2020 at 2:09 PM
Posts: 3,856
Thanks: 8483 in 67 Posts
Quote: Originally posted by echoweaver
Argh. I've been trying to read through the forum to get a picture of how Persistable data works, but I still don't think I get it. I'm just doing custom skills, and I'm hoping that if I copy from the sewing table by rote, I'll get away with it.... |
#12
30th Nov 2020 at 4:25 PM
Posts: 973
Thanks: 1897 in 12 Posts
Lyralei: I really appreciate you putting it on GitHub! I'm using it as a primary reference, and I have the beta package so that I can look at the resources. It's taught me a lot.
FWIW, I also have my stuff up in a GitHub repository: https://github.com/Echoweaver/Sims3Game
Now that I'm in the process of trying to break out the cat project into separate mods, the repository is likely to change quite a bit in the near future....
Echo Weaver's Simblr: http://echoweaver.tumblr.com/
A portrait in stubbornness - Playing the same legacy since 2009
Sample a Brave Legacy: http://sims3sample.illation.net
FWIW, I also have my stuff up in a GitHub repository: https://github.com/Echoweaver/Sims3Game
Now that I'm in the process of trying to break out the cat project into separate mods, the repository is likely to change quite a bit in the near future....
Echo Weaver's Simblr: http://echoweaver.tumblr.com/
A portrait in stubbornness - Playing the same legacy since 2009
Sample a Brave Legacy: http://sims3sample.illation.net
Who Posted
|