How schedulelua/schedulelua-framework works
Main components
• Loader & Host (MelonLoader / Unity) – the game engine entry point
• Core Framework – manages module registration, error handling, mod lifecycle
• Lua Engine (MoonSharp) – hosts and executes user scripts
• API Registry & Modules – C# bindings exposed to Lua (API/Base, Core, Economy, Law, NPC, Player, UI, etc.)
• Mod Management – discovers, loads, and configures Lua mods (Core/Framework/Mods)
• User Scripts & Resources – Lua files and example mods in Resources/
• External Dependencies – Unity types (proxies), MelonPreferences, MoonSharp library
Relationships and data flows
• Game Launch → MelonLoader initializes ScheduleLua (ModCore.cs)
• ModCore → Core Framework sets up ApiRegistry
• Core → registers each ILuaApiModule (all API/* folders)
• ApiRegistry ↔ MoonSharp: injects C# modules into the Lua environment
• Lua Engine → loads scripts from Resources/ and user folders → executes on game events
• Lua scripts → call API modules → proxy calls to Unity engine (via TypeProxies)
• UI modules (API/UI & API/Apps) → create in-game dialogs, phones, windows
• Mod Manager UI (Core/Framework/Mods/ManagerUI) ↔ MelonPreferences for config
• Error Handler intercepts script exceptions → logs via Unity console
Architectural patterns
• Plugin / Module registry – each API is an independent module implementing ILuaApiModule
• Proxy pattern – Unity engine types are wrapped by “Proxy” classes to safe-expose methods/properties
• Event-driven – Lua scripts subscribe to game events (day changes, player updates)
• Hot-Reload – Watcher in Core Framework triggers re-execution of scripts at runtime
Technologies & frameworks to call out
• MoonSharp (.NET Lua interpreter)
• MelonLoader (Unity mod loader)
• Unity Engine (Schedule I game types)
• C# .NET Standard (project code)
• MelonPreferences (config storage)
Essential elements to capture
• The startup sequence (MelonLoader → ModCore → ApiRegistry → Lua VM)
• Module registration and injection into the Lua context
• Script loading and hot-reload loop
• API calls flowing through proxies into Unity engine
• Error handling path
Putting it all together:
– Show API Modules calling “Unity Engine (Proxies)” as needed.
– Off to the side, show “Mod Manager UI” talking to “MelonPreferences (Config)”.
– Finally, annotate hot-reload and error-handler loops around the Lua VM.