Subnautica2-API-Library (S2ML)
Nautilus-style UE4SS Lua API framework for Subnautica 2 modding.
S2ML is a shared modding library that provides stable, reusable APIs for common Subnautica 2 mod features: events, player access, inventory operations, item/recipe/tech registration, world helpers, save utilities, notifications, sounds, and runtime discovery tooling.
What is this?
S2ML is a dependency library for modders and an optional framework for players.
- If you are a player: install S2ML when another mod says it requires it.
- If you are a modder: use S2ML to avoid rewriting low-level UE4SS glue and build cleaner mods faster.
Key Features
- Event-driven mod API (
OnPlayerSpawned,OnFabricatorOpened,OnPlayerDeath, and more) - Player helpers (location, depth, movement, spawn readiness, utility vectors)
- Inventory helpers (give/remove/count/containers/batch operations)
- Item + recipe + tech registration framework
- World helpers for spawning, querying, teleporting, and cleanup
- Save/load helpers with fallback patterns for Early Access builds
- Notification + sound wrappers
- Runtime discovery tools (
S2ML.Probe) for changing class/function names - Shared dependency bridge (
S2MLBridge.lua) for child mods - Example starter mod (
ModTemplate) included
Compatibility
- Game: Subnautica 2 (Early Access)
- Runtime: UE4SS Lua
- Recommended UE4SS: 3.0.1
- Engine target: UE 5.6 era runtime assumptions
Subnautica 2 is in Early Access. Internal class/function names may shift between updates.
Installation (Players)
- Extract this archive.
- Copy included folders/files into your game’s UE4SS
Modsfolder. - Confirm these paths exist:
ue4ss/Mods/S2ML/...ue4ss/Mods/shared/S2MLBridge.lua
- Enable S2ML in
mods.txt:
S2ML : 1
Enable your own mod after S2ML:
S2ML : 1 YourMod : 1
Installation (Modders)
Reference S2ML from your mod:
-- YourMod/Scripts/main.lua
local S2 = require("S2MLBridge")
S2.RequireVersion("3.1.0")
S2.Player.WhenReady(function(PC)
S2.Notify.Message("My mod loaded!")
S2.Inventory.Give("Battery", 2)
end)
Included Modules (High Level)
S2ML_Core- logging, safety wrappers, lifecycle/version checksS2ML_Events- pub/sub event bus + game hook wiringS2ML_Player- pawn/location/depth/movement helpersS2ML_Inventory- inventory and container operationsS2ML_Items- item registration/default patching/give fallbackS2ML_Recipes- recipe registration + fabricator injection flowS2ML_Tech- unlock/query helpersS2ML_World- spawn/query/teleport/destroy helpersS2ML_Notify- HUD/message fallback pipelineS2ML_Sounds- sound playback wrappersS2ML_Save- save/load utility wrappersS2ML_Assets- asset/object lookup helpersS2ML_Config- key/value config helpersS2ML_Time- delay/repeat/debounce/throttle utilitiesS2ML_Probe- in-game discovery tooling
In-Game Tools
Keybinds
Ctrl+P- run full class/function discovery scanCtrl+I- inspect nearest actorCtrl+U- dump player inventory
Console Commands (via ConsoleHelper)
s2ml version s2ml modules s2ml give <item> [count] s2ml save s2ml tp <X> <Y> <Z> s2ml tpf <distance> s2ml depth s2ml whereami s2ml api s2ml events s2ml probe s2ml inspect [class] s2ml inv s2ml debug s2ml loglevel <TRACE|DEBUG|INFO|WARN|ERROR> s2ml reset
Reporting Bugs
Please include:
- Subnautica 2 version/build
- UE4SS version
- S2ML version
- Reproduction steps
- Relevant
UE4SS.loglines
Known Limitations (Early Access)
- Some game APIs are discovered dynamically and may require updates after patches
- Recipe/tech/save internals can change between builds
- UI/HUD/sound paths may vary by build and content updates
Versioning
- Major - breaking API changes
- Minor - backward-compatible feature additions
- Patch - fixes and compatibility updates
Child mods should pin a minimum version with RequireVersion.
License
MIT
Credits
Created and maintained by forgeDMC. Community feedback and compatibility reports are welcome.