Quick Reply
Search this Thread
Senior Moderator
staff: senior moderator
Original Poster
#1 Old 16th Feb 2026 at 3:57 PM
Default S3PI - Code Snippets
Like the Code Snippet Jar thread for Sims 3 modding, here is a thread for information and code snippets for those working with S3PI for Sims 3 tools.

You can read more about and download S3PI from here.

It's also hosted on GitHub here.

[to be continued...!]
Lab Assistant
#2 Old 16th Feb 2026 at 4:54 PM Last edited by Destrospean : 12th Apr 2026 at 9:00 PM.
Alright, so I guess the first thing that should be mentioned is that Windows like to "block" downloads, and the wrappers for S3PI don't work unless they're unblocked. Many users use the default Windows archive extractor, which extracts all the contents of a blocked archive as blocked, and many of them come complaining, so I found a technical solution to this which is to unblock the contents of the folder of your program.

Below I have a class for platform-specific things, which is needed to determine whether a user is on Windows, so as to only unblock on Windows, as it'll throw a fatal exception on other platforms:


Notice in the above snippet the "FileUnblocker" subclass.
This should be called for everything within the program's folder when the program first launches, as follows:
Code:
if (Platform.IsWindows)
{
    foreach (var filename in System.IO.Directory.GetFiles(System.AppDomain.CurrentDomain.BaseDirectory))
    {
        Platform.UnblockFile(filename);
    }
}
Lab Assistant
#3 Old 12th Apr 2026 at 8:28 PM Last edited by Destrospean : 12th Apr 2026 at 9:31 PM.
Alright, I haven't been contributing to this thread like I promised @zoe22 I would, so allow me to add some things:

Lab Assistant
#4 Old 12th Apr 2026 at 8:55 PM Last edited by Destrospean : 13th Apr 2026 at 5:52 PM.
If you ever need to reference the game packages, I have found this to be a convenient way to do so (make sure GameFolders.xml is in your compiled application's folder):


Below is an example of finding a resource in the game files by its instance ID from the packages of the specified dictionary:
Code:
public static Tuple<IPackage, IResourceIndexEntry> FindResourceByInstance(Dictionary<PackageTag, IPackage> gamePackages, ulong instance)
{
    foreach (var gamePackage in gamePackages.Values)
    {
        var found = gamePackage.FindAll(x => x.Instance == instance);
        if (found.Count > 0)
        {
            return new Tuple<IPackage, IResourceIndexEntry>(gamePackage, found[0]);
        }
    }
    return null;
}

I also recommend using the attached modified version of GameFolders.xml for support by case-sensitive filesystems and by games that have been decompressed with TurboTravel.
Attached files:
File Type: zip  GameFolders.zip (2.3 KB, 2 downloads)
Back to top