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 24th Jan 2019 at 5:58 PM Last edited by Renha : 24th Jan 2019 at 6:24 PM.
Default Include data for the script to .package
Hello! I want to include some data into the .package, for my script to use the data.

The data I want to pass to the script is a list (array, tuple) of dictionaries, like that:
[ {'key1':4,'key2':7.002,'key3':'woohoo'}, {'key1':2,'key2':1.08,'key3':'secretlysad'} ]

I would be probably almost as happy with just the string, if I could use say JSON.

So, what the easiest way to do that? I'm interested both in methods of including
arbitrary data into .package and methods of reaching that data from python script.
Advertisement
Test Subject
Original Poster
#2 Old 24th Jan 2019 at 6:21 PM
Couple of options I could imagine myself are using string resources and XML-files.
For the second option I probably could go the way described in the script code of
http://www.modthesims.info/d/621327...ump-script.html
but it would be better to be more specific and select needed resource by its name,
which again I don't know how to achieve.

Anyway, even if that would work, I have no idea on how to add custom XML-data
into the .package file. About the other option, string resources, I know even less.
Test Subject
Original Poster
#3 Old 24th Jan 2019 at 7:14 PM Last edited by Renha : 25th Jan 2019 at 9:52 AM.
Okay, STBL or string resources could be somewhat useful according to tutorial
http://modthesims.info/showthread.php?t=573055
but not very useful or convenient for script to get the data in useful form. So... XML?
Deceased
#4 Old 27th Jan 2019 at 4:52 AM
I'd recommend using module tuning to load the data. You could make the tuning contain lists if you want to load it all from XML, or just a single tuning string and stuff that JSON into the string. I'd suggest the former, it's more "Sim-style". There's other solutions you could do, but that lets the game do most of the heavy lifting for you using that approach.

Unfortunately, I don't have the time right this moment to make an example as I'm in the process of recovering after my old computer died an untimely death. Maybe at some point tomorrow or Monday I could whip up an example.
Test Subject
Original Poster
#5 Old 28th Jan 2019 at 8:22 AM
Okay, thank you, I’ve looked up into the topic and looks like I need examples for sure. Good luck with the recovery!
Deceased
#6 Old 29th Jan 2019 at 10:11 AM
I think the attached package and script demonstrate more or less what you're trying to accomplish. This creates a module tuning which is a list of dicts.

It's not a compiled script, so just unpack the whole folder structure in the zip file into your mods, so the script should be in the Mods\GetDataFromPackageExample\Scripts\ folder in order to work. To view the data run the 'getdata' cheat command.

There's some comments in the source code that should make it fairly clear what is going on, and demonstrates that the dict which gets loaded is stored as a frozendict which is immutable.

You'll likely want to look at my thread on using module tuning for notifications as there's some important stuff there on numbering the instance for the module tuning itself. See http://www.modthesims.info/showthread.php?t=622129

Finally, I am watching this thread in case you have any questions about this, so if something doesn't click just yell.
Attached files:
File Type: zip  GetDataFromPackageExample.zip (1.8 KB, 45 downloads) - View custom content
Back to top