Module loader "Loader" for any game you creating

Hey, i was developing games for 4 years and after a lot of time i decided to make a universal module loader for any game i creating

This module loader has good configuration

Lets see what it can do:

Setting up and Configuration

Just run loader.setup() once and it will setup everything for future workflow

Configuration contains ServerDirectory, ClientDirectory, ServerConfigsDirectory, ClientConfigsDirectory, ServerIdentifier and ClientIdentifier values that can be found in Configuration inside of module loader

ServerDirectory and ClientDirectory (StringValues) is used to find base folders that contains subdirectories for modules
ServerDirectory must be in ServerStorage
ClientDirectory must be in ReplicatedStorage

ServerConfigsDirectory and ClientConfigsDirectory (StringValues) is used to find subdirectory for configurations
ServerConfigsDirectory must be in ServerDirectory
ClientConfigsDirectory must be in ClientDirectory

ServerIdentifier and ClientIdentifier (IntValues) is used to identify values that later you will use for loading modules

Default loading

loader.load(MODULE_PATH, MODULE_SIDE)
Instead of require() you just load module and you get required module from cache (if it already was loaded before) or loads it in cache and returns it
for example: loader.load("ModulesSubdirectory/ModuleName", 0) loads server module that can be found in ServerDirectory.ModulesSubdirectory.ModuleName

What is MODULE_PATH? Basically you can access any module by path that contains subdirectory and module name separated by /

What is MODULE_SIDE? Its a identifier for getting server or client module

Configuration Load

loader.load(CONFIG_NAME, CONFIG_SIDE)
You can load multiple modules at once and execute their .init() function while loading
for example: loader.loadConfiguration("ConfigName", 0) loads server configuration in ServerDirectory.ServerConfigsDirectory.ConfigName

Modules always execute in order and they must be one sided, if module has .init() function it executes too
Config looks like that:

return {	modules = {	"MyFolder/MyModule",	"OtherFolder/OtherModule"	} } 

Lazy Loading

loader.lazyLoad(MODULE_PATH, MODULE_SIDE)
Default load but actual module gets loaded only when module[key] was used
for example: loader.lazyLoad("ModulesSubdirectory/ModuleName", 0) works same as base loader.load() but module gonna get actually loaded only when you call module variable

Other utilities

  • loader.isLoaded(MODULE_PATH, MODULE_SIDE) - checks if module was loaded before
  • loader.clearFromCache(MODULE_PATH, MODULE_SIDE) - removes module from cache
  • loader.getLoadedModules() - returns all loaded modules

Link: https://create.roblox.com/store/asset/121954404435466

4 Likes

Thanks! I’ll give this a try!

From the outside, It seems good, I haven’t tried it tho, I will after I have posted this

Oh wait nevermind, Did you forget to make it public?

Sorry for not replying to long, is it still unavalible?
If it is, do you know how to fix it?

ew

Does it have intellisense?β€Žβ€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž

why don’t you try it and see

no timeβ€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž β€Ž

Yes, It says "We couldn’t find the page you were looking for

404 Page not found" when i open it.