Search this Thread |
![]() |
![]() |
lizcandor
Original Poster
|
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)) |
|
|
![]() |
#2 |
Battery
|
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 ? |
|
Last edited by Battery : 29th Nov 2020 at 5:05 PM.
|
![]() |
#3 |
gamefreak130
|
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:
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 |
|
|
|
![]() |
#4 |
lizcandor
Original Poster
|
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:
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! |
|
|
![]() |
#5 |
Battery
|
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 ? |
|
|
![]() |
#6 |
gamefreak130
|
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 ![]() |
"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 |
|
|
|
![]() |
#7 |
lizcandor
Original Poster
|
@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 |
|
|
![]() |
#8 |
echoweaver
|
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 |
|
|
|
![]() |
#9 |
lizcandor
Original Poster
|
I keep thinking I understand persistable data now and then realizing that I actually do not ![]() |
|
|
![]() |
#10 |
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.... |
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 | |
Lyralei
|
Quote:
![]() ![]() | |
|
|
![]() |
#12 |
echoweaver
|
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 |
|
|
|
![]() |