URL: https://wiki.studiominus.nl/details/lifecycle.html
Title: People Playground Modding - Mod Lifecycle
==================================================

Mod Lifecycle
Mods have a simple lifecycle. A lifecycle describes when a mod is created, what it does during its lifetime, and when it is destroyed.


    
        1. Load
        Main menu loaded
        mod.json is found and interpreted. All referenced scripts are read.
    
    
        2. Compile
        Mod loaded
        All loaded scripts are compiled and written to a DLL by the compiler server. The DLL is loaded into memory. OnLoad is called.
    
    
        3. Execute
        Map loaded or catalog updated
        ModAPI.ModMetaData is set and `Main` is called.
    
    
        4. Termination
        Game is exited
        OnUnload is called. All resources are freed. 
    

Note that OnLoad is only called if the mod is active after compilation. If it's inactive (the default), it will call OnLoad once activated and never again.
A mod may spit out errors in the compilation stage (or other stages). The errors are always logged to the Logs folder.