Hi there! You are currently browsing as a guest. Why not create an account? Then you get less ads, can thank creators, post feedback, keep a list of your favourites, and more!
Test Subject
Original Poster
#1 Old 16th Mar 2015 at 4:26 AM
Default Save additional data
Hi,

Is there some simple way to save a dict() when the game is saved, and have some callback called to retrieve it again after load? If the dictionary is just limited to simple data types like int, float, string for the keys and values, I don't mind. I just need some simple way to save data as part of the savegame.

(preferrably some way that doesn't require getting all the protobuf tools and changing the .proto files which seemed complicated to me, especially since I don't even know where the game stores them)

In fact, I'd also settle for a string if it isn't too limited in length. Python has a nice JSON module after all. Just something that is exclusive for my nice little mod and which doesn't disturb others or the core game.

Any help appreciated!
Advertisement
Deceased
#2 Old 16th Mar 2015 at 6:50 AM
Well, crafted objects can have an "inscription" which should be able to store arbitrary text (e.g. JSON). Another option might be to create a fake sim and store some information into their name fields. I know - these are both kind of hacks, especially the latter idea, but since EA didn't see fit to give us a method to store arbitrary data easily a hack may be the best way. I suppose the most likely method would depend on what you're trying to attach the data to, a sim, an object, a household, or the world itself?

Ideally, any method, whether elegant or a hack, should be able to be duplicated by other mod authors without stomping on another mod's data, and without creating the possibility of corruption.
Test Subject
Original Poster
#3 Old 16th Mar 2015 at 8:12 AM
How can I attach data to a sim?

I saw no way without actually locating the .proto files and changing them, which seemed kinda intrusive to me (that would explode if there is more mod than mine which tries that I guess?) or e.g. hacking data into the firstname with some weird separation char, but that would ruin the savegame if the mod was removed and if the game would do any sanitation of that field that would also be bad.

As for crafted objects, wouldn't they need to be somewhere in the world? What if the player finds them and messes with them?
Test Subject
Original Poster
#4 Old 17th Mar 2015 at 3:04 AM
I asked in the official forums now: http://forums.thesims.com/en_US/dis...e-what-about-it
Test Subject
#5 Old 28th Aug 2018 at 1:07 PM
Hm, way with fake sim looks not that bad. How long could sim name be?
Deceased
#6 Old 29th Aug 2018 at 10:36 AM
Quote: Originally posted by Renha
Hm, way with fake sim looks not that bad. How long could sim name be?


No limit that I know of to either first or last name, there probably is one but if memory serves I think I went as high as 256 or maybe it was even 512 or 1024 characters. For the next leap up I'd suggest trying to store something like 32k and see what happens

If I was going to seriously store a lot of data, I'd probably try something like convert it to JSON, gzip it and then encode it to a base64 string (all of the necessary libraries for that should be in the game's libs). For smaller amounts of data just converting it to JSON might work well.

It's still very much a hack though. Wish EAxis would've given us an arbitrary storage method. There are some mods that store data in a subfolder of the TS4 folder using the save game number, can't think of which ones, but that's probably a much safer and stabler method. Easier for a player to delete data stored like that as well should it become necessary to do so and I think that's probably enough of a good reason to avoid the hack of storing data in a fake sim's name. Still, hacking in something that probably shouldn't be done that way is always fun
Deceased
#7 Old 29th Aug 2018 at 10:40 AM
Oh, for very small amounts of data back when I wrote door locks, I encoded the data into custom statistics with no decay. There's 21 bits of precision (single precision float) that you can store in each statistic if I remember the numbers correctly.
Deceased
#8 Old 8th Nov 2018 at 2:11 AM
Following up on this thread, I have been working on a library class which will allow modders to store arbitrary data for their mods into the save game. I mentioned the possibility of storing data on a fake sim using JSON and base64 strings; however, I instead settled on a somewhat different approach that makes it more flexible. It seems to be working well, and will hopefully be quite easy for script modders to use it.

More details to follow, I've got it to the point where it reliably saves and reloads data without any game breakage. I've tested storing, loading and verifying as much as 64 MB of random data. I just want to make it as easy and reliable to use as possible, with some intelligent error handling for some possible things that could go wrong.
Deceased
#9 Old 28th Nov 2018 at 8:16 AM
So the Sims Data Storage Library is almost complete. Everything is functioning smoothly, but there's some user-friendliness I want to add, then a matter of documenting the API for script modders to be able to use it!

Basic features:
  • All data storage types work much like a standard Python dict
  • Save/retrieve values to a "global" (not linked to an individual save game) data storage easily
  • Easily save/retrieve values in the save game file
  • Super easily save/retrieve values from a SimInfo (also saved in the save game file)
  • Mods that use the library will not need to bother with any file handling / reading or writing, that's all handled internally by the library.
  • Mods can register callbacks with the data manager to get notified
    • When the global data is available (as soon as script mods are all initialized)
    • When save game data has been loaded (lot loading completed)

The documentation part will likely take some time, but the code itself is looking good, stable and easy to use.
Test Subject
#10 Old 3rd May 2019 at 2:12 PM
I was curious if you still planned to release your storage library?
Deceased
#11 Old 3rd May 2019 at 6:38 PM
Still intend to, yes. I lost a lot of stuff in a hard drive crash a few months ago and been working on other things since. I still have a good copy of it, but lost all the changes I'd made to clean up the code and start making it end-user friendly. I'll get back to it fairly soon though.
Back to top