S3IO: In-Game File Access API for Script Modders

SCREENSHOTS
Downloaded 30 times 10 Thanks 0 Favourited 1,165 Views
 Say Thanks!
S3IO

Native I/O bridge for The Sims 3. Gives script mods the ability to read and write files from inside the game.

Source code & full documentation on GitHub

Why S3IO?

The Sims 3 runtime is sandboxed and does not include System.IO. Previous community solutions relied on a "delay_ms" parameter that often requires fine tuning per machine. S3IO eliminates timing dependence entirely — no configuration file, no delay tuning, no per-machine adjustment. Just install and go.

Getting Started

Requirements
  • An ASI loader in your game's Bin directory (ddraw.dll — the same one used by other ASI mods like the Smooth Patch). One is included in the download.
  • The Sims 3 with any combination of expansion/stuff packs.

Installation
  • Copy ddraw.dll and S3IO.asi to your game's Bin directory (e.g. C:\Games\The Sims 3\Game\Bin\). If you already have a ddraw.dll from another mod, skip it — they're the same ASI loader.
  • Copy S3IO.package to your Mods folder (e.g. Documents\Electronic Arts\The Sims 3\Mods\Packages\).
  • Delete scriptCache.package from your Sims 3 user directory if it exists.
  • Launch the game. S3IO initializes automatically.

For Modders

Reference S3IO.dll at compile time and you're good to go:

Code:
/r:"path\to\S3IO.dll"


Code:
using S3IO;

// Read a file
string text = ModIO.File.ReadAllText(@"C:\path\to\file.txt");

// Write a file
ModIO.File.WriteAllText(@"C:\path\to\file.txt", "Hello world");


S3IO initializes itself — just call ModIO.File.*, ModIO.Directory.*, or ModIO.System.* and it handles the rest.

Important
Do not copy S3IO's ModIO or FunctionTask classes into your own mod. Reference S3IO.dll as a shared dependency. Copying them creates a second IPC buffer that the native side can't reliably distinguish from the real one.
API Reference

ModIO.File

Code:
bool exists = ModIO.File.Exists(@"C:\path\to\file.txt");


Code:
byte[] data = ModIO.File.ReadAllBytes(@"C:\path\to\file.bin");


Code:
string text = ModIO.File.ReadAllText(@"C:\path\to\file.txt");


Code:
ModIO.File.WriteAllBytes(@"C:\path\to\file.bin", data);


Code:
ModIO.File.WriteAllText(@"C:\path\to\file.txt", "Hello");


Code:
ModIO.File.AppendAllBytes(@"C:\path\to\log.bin", data);


Code:
ModIO.File.AppendAllText(@"C:\path\to\log.txt", "New entry\n");


Code:
ModIO.File.Delete(@"C:\path\to\file.txt");


ModIO.Directory

Code:
bool exists = ModIO.Directory.Exists(@"C:\path\to\folder");


Code:
ModIO.Directory.Create(@"C:\path\to\folder");


Code:
ModIO.Directory.Delete(@"C:\path\to\folder", false);    // non-recursive


Code:
ModIO.Directory.Delete(@"C:\path\to\folder", true);     // recursive


Code:
List<string> files = ModIO.Directory.GetFiles(@"C:\path\to\folder");


Code:
List<string> dirs = ModIO.Directory.GetDirectories(@"C:\path\to\folder");


ModIO.System

Code:
string docs = ModIO.System.GetDocumentsPath();


All file/directory methods return true/false for success/failure. Read methods return null on failure. List methods return an empty list on failure.
Advertisement:
Other Download Recommendations: