Syscore
- Wally Package: Syscore
Syscore is a module that allows you to easily manage the initialization of your modules in a specific order. This is useful for when you have modules that depend on each other and need to be initialized in a specific order. You can enable/disable debug mode to see the load order of your modules.
Any module that you have can be loaded with Syscore! No special requirements needed inside your modules.
If you have a Init() method in your module, Syscore will call it when initializing your module. If you do not have an Init() method, Syscore will skip it.
You can also specfiy a Prioty, Name, and Icon for your module. This is useful for debugging purposes.
Here is a few examples of how a module could look like with Syscore:
local module = {
Name = "Module1",
Priority = 1,
Icon = "😁"
}
function module:Init()
print("Module1 initialized!")
end
return module
local module = {}
module.Priority = 2
return module
local module = {}
return module
Here is an example of how to use Syscore to initialize a folder of modules:
local Syscore = require(path.to.Syscore)
local folder = game:GetService("ReplicatedStorage").Modules
Syscore.AddFolderOfModules(folder)
Syscore.Start()
NOTE
When using Syscore you will need to require it from a local script, or server script.
Once you have added all of your modules, you can call `Syscore:Start()` to initialize them.
Properties
ShowLoadOrder
BooleanSyscore.ShowLoadOrder:
boolean
Determines whether or not to show the load order of your modules when initializing them. This debug print is useful for debugging purposes. Default, this is set to true.
local Syscore = require(path.to.Syscore)
Syscore.ShowLoadOrder = true
LoadTime
NumberSyscore.LoadTime:
number
The time it took to load all of the modules. This is useful for debugging purposes.
local Syscore = require(path.to.Syscore)
Syscore.AddModule(module)
Syscore.Start()
print(Syscore.LoadTime)
Functions
AddFolderOfModules
Requires all modules that are direct children of the folder.
local Syscore = require(path.to.Syscore)
local folder = game:GetService("ReplicatedStorage").Modules
Syscore.AddFolderOfModules(folder)
AddModule
Add a module to be initialized.
local Syscore = require(path.to.Syscore)
local module = require(path.to.module)
Syscore.AddModule(module)
AddTableOfModules
Add a table of modules to be initialized.
local Syscore = require(path.to.Syscore)
local modules = {
require(path.to.module1),
require(path.to.module2),
require(path.to.module3),
}
Syscore.AddTableOfModules(modules)
Start
Initializes all modules based on their priority. Returns a table of errors that occured during initialization.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Syscore = require(path.to.Syscore)
Syscore.AddFolderOfModules(ReplicatedStorage.ModulesFolder)
Syscore.Start()