modUtils Reference
Estimated reading time: 2 minuteswindow.modUtils is ModLoader's main public API for Mod authors.
Mod Queries
getModListName()
Returns names of all loaded Mods.
getMod(modName)
Returns the Mod info object for the given name.
getModZip(modName)
Returns the zip reader for the given Mod.
getNowRunningModName()
Returns the name of the Mod whose script is currently running. Useful for reusable Mod templates that need to know their own name.
ModLoader Query APIs
These are query methods on the ModLoader instance, accessed via window.modSC2DataManager.
Direct access to modOrder is not allowed since v2.0.0. The data structure changed significantly; use the APIs below instead to ensure backward compatibility. Use getModByNameOne, getModZip, and getModEarlyLoadCache for common lookups.
ModLoader.getModByNameOne(modName)
Look up Mod info by name.
ModLoader.getModZip(modName)
Look up Mod zip by name.
ModLoader.getModEarlyLoadCache()
Read a safe snapshot of loaded Mods during EarlyLoad.
These methods cannot be used during EarlyLoad.
ModLoader.getModCacheMap()
Returns a read-only Map of Mod names to info.
ModLoader.getModCacheOneArray()
Returns an Array for traversal; mutating it does not affect ModLoader internals.
ModLoader.getModCacheArray()
Returns the Mod cache array.
ModLoader.getModCacheByNameOne(modName)
Look up cache by Mod name.
ModLoader.checkModCacheUniq()
Verify uniqueness. Call after manually changing Mod data.
ModLoader.checkModCacheData()
Verify internal consistency. Call after manually changing Mod data.
Inter-Mod Communication: ModInfo.modRef
ModLoader uses ModInfo.modRef to expose APIs between Mods.
Mod A (loads first) — Expose API
Mod B (loads later) — Call API
Because of load order, when calling another Mod's modRef in earlyload, ensure the target Mod has already loaded and set modRef. Preload or later is usually safer for inter-Mod calls.
