RBXModuleLoader
Version 1.0.0
What is a Module Loader?
A “Module Loader” is something that’s used to load a bunch of modules, it is mainly used for the SSA (Single Script Architecture) which is for game organisation.
Why use this?
RBXModuleLoader is an advanced module loader with features such as debugging that can help you spot errors, view module loading times, loading order, etc.
It has a variety of settings, and includes features like changing the loading order, prioritising certain modules, and you can define custom filtering behaviour!
Example Code
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ModuleLoader = require(ReplicatedStorage.ModuleLoader)
local myModules = script.Parent.Services
-- Optionally changing the settings
ModuleLoader.ChangeSettings({
DEBUG_MODE = true,
WAIT_FOR_SERVER = true,
LOADING_PRIORITIES = true,
})
-- Loading modules (all of the descendants),
-- returns a table of the required modules
local modules = ModuleLoader.LoadDescendants(myModules, function(module: ModuleScript)
-- An optional predicate function / custom filtering function
-- Must return true or false
-- This means it will only load modules that have "Service" in their name
if module.Name:lower():match("service") then
return true
end
return false
end)
-- Start / Init
ModuleLoader.RunModules(modules, "Init")
ModuleLoader.RunModules(modules, "Start")
Functions
| Load - Loads the given modules that are in a table, optional predicate function | |
|---|---|
| LoadChildren - Loads all the children of the parent passed, optional predicate function | |
| LoadDescendants - Loads all the descendants of the parent passed, optional predicate function | |
| RunModules - Runs the method passed on the loaded modules | |
| GetModule - Returns the loaded module of the name passed | |
| IsServerLoaded - Returns if the server has loaded (only used by the server) | |
| IsClientLoaded - Returns if the client has loaded (only used by the client) | |
| ChangeSettings - Change the settings of the module loader |
Any Feedback is Appreciated!
by @I_p2z