Quick Reply
Search this Thread
Test Subject
Original Poster
#1 Old Yesterday at 10:42 AM
Default Script mod loads but static constructor never fires — [Tunable] kInstantiator not triggering
I'm building a standalone Sims 3 script mod called SimReserve. The assembly loads correctly (confirmed in ErrorTrap's Loaded Assemblies list every session) but the static constructor never fires — no notifications appear and no interactions inject onto any object.

I have (perhaps foolishly) also been using Claude Code in addition to Visual Studio and S3PE **What I've verified/tried:**
- `[assembly: Tunable]` and `[assembly: PersistableStatic]` both present in AssemblyInfo.cs
- `[Tunable] public static bool kInstantiator = false;` on the field directly
- Bootstrap class is a normal non-static `public class` (not `static class`)
- Compiled with Roslyn (linker version 48.0, matching working mods)
- corflags `0x00000003` (ILONLY + 32BITREQUIRED) matching working mods
- XML resource type `0x0333406C` with instance ID = FNV64 of `SimReserve.Core` generated by S3PE's FNV64 button
- Packaged manually in S3PE - Tried both `World.OnWorldLoadFinishedEventHandler +=` (public accessor) and raw `ldsfld/Delegate.Combine/stsfld` on `sOnWorldLoadFinishedEventHandler` via IL patch
- Compared byte-for-byte against twinsimming_Attend University Online which works in my game
- Tested a minimal NomTest mod mirroring the Pausinator tutorial exactly — also fails

**Core.cs:**
```csharp
using System;
using Sims3.Gameplay.CAS;
using Sims3.Gameplay.EventSystem;
using Sims3.Gameplay.Utilities;
using Sims3.SimIFace;
using Sims3.UI;

namespace SimReserve
{
public class Core
{
[Tunable]
public static bool kInstantiator = false;

private static string sBootError = null;

static Core()
{
try
{
World.OnStartupAppEventHandler += OnStartupApp;
LoadSaveManager.ObjectGroupsPreLoad += OnPreLoad;
World.OnWorldLoadFinishedEventHandler += OnWorldLoadFinished;
World.OnWorldQuitEventHandler += OnWorldQuit;
}
catch (Exception ex)
{
sBootError = ex.Message;
}
}

private static void OnPreLoad() { }

private static void OnStartupApp(object sender, EventArgs e)
{
string msg = sBootError != null
? "SimReserve boot FAILED: " + sBootError
: "SimReserve: startup fired OK";
StyledNotification.Show(new StyledNotification.Format(
msg, StyledNotification.NotificationStyle.kGameMessagePositive));
}

private static void OnWorldLoadFinished(object sender, EventArgs e)
{
StyledNotification.Show(new StyledNotification.Format(
"SimReserve: world load fired",
StyledNotification.NotificationStyle.kGameMessagePositive));
try
{
if (Household.ActiveHousehold != null)
StartSimReserve();
else
EventTracker.AddListener(EventTypeId.kEventSimSelected,
new ProcessEventDelegate(OnSimSelected));
}
catch (Exception ex)
{
StyledNotification.Show(new StyledNotification.Format(
"SimReserve inject error: " + ex.Message,
StyledNotification.NotificationStyle.kDebugAlert));
}
}

private static ListenerAction OnSimSelected(Event e)
{
try
{
if (Household.ActiveHousehold != null)
{
StartSimReserve();
return ListenerAction.Remove;
}
}
catch { }
return ListenerAction.Keep;
}

private static void OnWorldQuit(object sender, EventArgs e) { }

private static void StartSimReserve()
{
LedgerManager.OnWorldLoad();
SimReserveInjector.InjectAll();
SimReserveInjector.InjectAllSims();
SimReserveInjector.SetupReactivity();
}
}
}
```

**AssemblyInfo.cs:**
```csharp
using System.Reflection;
using System.Runtime.InteropServices;
using Sims3.SimIFace;

[assembly: AssemblyTitle("SimReserve")]
[assembly: AssemblyDescription("SimReserve Financial Simulation Mod")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SimReserve")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: Tunable]
[assembly: PersistableStatic]
[assembly: ComVisible(false)]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: Guid("A1B2C3D4-E5F6-7890-ABCD-EF1234567890")]
[assembly: AssemblyFileVersion("1.0.0.0")]
```

Any help identifying what's missing would be greatly appreciated. Running game version 1.67.2
Attached files:
File Type: zip  SimReserve_Source.zip (7.2 KB, 4 downloads)
Your Average Simmer
staff: trainee moderator
#2 Old Yesterday at 11:06 PM
Hi,

We might not have enough context... did you by any chance have an _XML resource in the same package that had something along the lines of the following?



The instance of the _XML resource has to same FNV64 hash of the namespace + class name of the class with kInstantiator as the tuning value.

In fact, I actually made a tool that can generate the _XML tuning resources by the user dragging the .package file with the assembly inside of it on top of the executable. It will automatically add the _XML resources to the package (you'll see them when you open the package after dragging it on top of the exe):

https://github.com/Destrospean/Sims...gUtils/releases
Screenshots
Test Subject
Original Poster
#3 Old Today at 1:01 AM
Quote: Originally posted by Destrospean
Hi,

We might not have enough context... did you by any chance have an _XML resource in the same package that had something along the lines of the following?



The instance of the _XML resource has to same FNV64 hash of the namespace + class name of the class with kInstantiator as the tuning value.

In fact, I actually made a tool that can generate the _XML tuning resources by the user dragging the .package file with the assembly inside of it on top of the executable. It will automatically add the _XML resources to the package (you'll see them when you open the package after dragging it on top of the exe):

https://github.com/Destrospean/Sims...gUtils/releases


Wow! You're a wizard lmao. I had to edit and update the XML file in s3pe. Thank you!
Back to top