ModuleSystem API
Estimated reading time: 3 minutesOverview
ModuleSystem handles module registration, dependency ordering, and lifecycle scheduling. Most content mods should not register framework modules—use addonPlugin script entries instead. Only use maplebirch.register when you intentionally extend internal framework capabilities.
For architecture and boot flow see Core Architecture.
Registering modules
register(name, module, dependencies?)
Registers a module (delegates to ModuleSystem.register).
- @return
boolean—trueon success;falseif the name already exists.
Extension modules get a source (owning mod name) recorded automatically when AddonPlugin loads your module scripts—no fourth source argument or runWithSource wrapper required.
get(name)
Returns a registered module instance.
dependencyGraph
Dependency metadata per module:
Exposed modules (EXPOSED)
Set exposed: true on the module object. After registration the state is EXPOSED and the object is mounted at maplebirch[name].
Exposed modules do not run the normal lifecycle (preInit / Init / loadInit / postInit) and do not appear in the disable UI. The dependency graph treats EXPOSED modules as satisfied dependencies. Registration fails if maplebirch[name] is already taken.
Module states
Pre-init completion is tracked separately in an internal preInitialized set; modules move to MOUNTED after main init.
Lifecycle methods
Dependency rules
- A module initializes only after all dependencies are satisfied (transitive closure applies).
EXPOSEDmodules count as satisfied dependencies.- If a dependency is
ERRORorDISABLED, dependents do not initialize. - Circular dependencies are detected at registration time.
Notes
- Prefer
scriptover framework module registration for content mods (v3.2.5 simplified registration—see changelog). - Use mod-prefixed names to avoid clashes with built-ins or other mods.
- A failed module does not block others.
- Protected modules (
protected) cannot be disabled from the UI; extension modules remain toggleable whensourceis tracked by the framework.
