Code Execution Model
The code execution model in Mince follows a specific, sequential boot process to ensure that all dependencies are loaded and ready before any game logic runs. This process prevents race conditions and provides structure for your project.
The boot process is as follows:
-
Require Mince: The process begins when you
require()the main Mince module. At this point, Mince mounts itself to_G.MinceRefand loads its internal addons. -
Client-Server Handshake: A built-in handshake automatically runs to ensure that the server and client are ready to communicate with each other. This guarantees that remote calls can be made safely once your code starts running.
-
User-Defined Booting: After the initial setup, you take control. You define where your game’s code and configurations are located by calling
Mince:LoadConfig()andMince:LoadModules().LoadConfig(): This function takes an Instance and attaches every ModuleScript found inside it to theMince.Configtable, making configuration values easily accessible throughout your project.LoadModules(): This function tells Mince where to find your gameplay modules.
-
Start Mince: Once the paths are configured, you call
Mince:Start(). This initiates the main execution sequence. -
Module Loading: The framework
requires every module found byLoadModules(). From this point on, any loaded module can be retrieved by callingMince:Get(). This allows modules to access each other before their setup logic runs. -
Setup Phase: The framework iterates through every loaded module and calls the
Setupfunction within each one. This phase is used for initial setup logic, like connecting events or initializing states. -
Post Method Phase: After all
Setupfunctions have completed, the framework again iterates through every module and calls theGameStartfunction in each. This is useful for logic that needs to run after all modules have been initialized. -
Bootstrap Complete: Once all functions have run, the Mince framework is officially bootstrapped and fully operational.
Execution Flow Diagram
The following diagram illustrates the entire boot process from start to finish.